Using Tables to Start and Stop Music
I have a game I'm working on, and music is playing in the background. I want players to have the option to start and stop it using tables, but I don't know anything about tables! Can someone help?
Best Answer
-
gyroscope I am here.Posts: 6,598
Rule: When touch is pressed
Rule (nested with above): When scene.ToggleIcon is false
Change Image to On icon
Play Music
Change Attribute scene.ToggleIcon to true
Otherwise
Change Image to Off icon
Stop Music
Change Attribute scene.ToggleIcon to false
There's nothing that can go wrong with that simple set of Rules/behaviours...
There is one small amendment though; probably best to make the scene attribute ToggleIcon a game attribute.""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Answers
@VibraKnife
Hallo, tables are very useful in GSC and can help out with the more complex tasks to be made easier. There are quite a few tutorials on tables, one being in the Cookbook that'll teach you about them:
http://cookbook.gamesalad.com/tutorials/2/parts/25
And @tshirtbooth has quite a few tutorial videos involving tables at gshelper.com
So back to your question, you could use tables to solve your problem but it really isn't necessary in this case; it's really straightforward, using a boolean attribute and a few rules/behaviours.
I've quickly amended a file I did for someone else to include the start and stop music aspect that'll help you:
https://dl.dropbox.com/u/14060718/MUSIC ON OFF DG.gameproj.zip
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
And rejecting my answer doesn't make what I said incorrect either. I guess you'll be rejecting this comment as well.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
OK, @VibraKnife – just to confirm then, do you want your music to start and stop, then start again from the beginning, etc; or start, then pause, then carry on, etc?
If it's the second one, let me know, and I'll amend the file soon and post it for you.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
In that case, the game file I put together works fine here and so should work fine for you as well; I'm not certain why you're finding it wrong.
Give me a minute and I'll write the Rules here from the game file for you to check against the copied rules in your game.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
And as the gamefile I amended included changing the button graphic, which you didn't ask for in your question, here it is without that, in case you don't want that:
Rule: When touch is pressed
Rule (nested with above): When scene.ToggleIcon is false
Play Music
Change Attribute scene.ToggleIcon to true
Otherwise
Stop Music
Change Attribute scene.ToggleIcon to false
And just change ToggleIcon to ToggleMusic or something.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
OK, glad it worked out in the end. :-) (Shame you can't "un-reject" my answers...) :P
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps