Playing a sound file only once
andrewhnovak@gmail.com
Member, PRO Posts: 77
Im building an endless runner and after collecting 4 coins I have a sound file that plays. The only thing is that when you die and start over every 10-20 seconds or however long it takes you to die, you hear the same file over and over again and it's kind of annoying. Is there a way to play the sound file only once, so If I die I don't hear it again. The only way I want you to hear it again is if you quit the application from running and relaunch it, which would eliminate hearing it over and over.
Comments
Make a Boolean Attribute called Played (or whatever) starting as False
The sound should only play once.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
Have you got loop checked on the music, try unchecking loop.
Darren.
I set it up as best as I can. This is my first game though so forgive my noobness. What I typed under condition isn't registering correctly. I'm pretty sure I did it wrong. I'm just not sure how. Here's a screenshot.
My guess is that you have another Play Sound behavior in that actor or another actor on the scene, or that you have unlocked an "instance" of the actor and are looking at the prototype rules by mistake.
Try removing that actor from the scene and re-adding it to the scene which will force it to use the prototype rules. Also check other actors for Play Sound behaviors. It shouldn't play over and over again UNLESS game.Diamonds is changing from 4 to something other than 4 and then back to 4 again, which would play the sound once.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
When I click on a different actor and click back to DiamondsCollected(Prototype), what I type disappears and it just says "type or drag in a condition" again. I don't think the Attribute "Played" is registering correctly because when I drag a behavior in that block and use the Attribute Browser to change the attribute within the if statement, I don't see an option for Played. In the image I just posted I'm trying to change "game.FireMissiles" to the Played attribute, but there is no attribute named "Played" listed. What do you think?
I don't have a lot of experience with the Windows version of GS, but did you set up a new Attribute named Played already? You'd need to do that first.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
That was the key to my problem. I didn't have the attribute created. The more I use gamesalad, the more I learn! Thanks Jamie
You're welcome!
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page