Playing a sound file only once

andrewhnovak@gmail.comandrewhnovak@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

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Make a Boolean Attribute called Played (or whatever) starting as False

    Then set up a Rule that says if Played is False
    Play Sound
    Change Attribute Played to True
    

    The sound should only play once.

  • UtopianGamesUtopianGames Member Posts: 5,692
    edited March 2014

    Have you got loop checked on the music, try unchecking loop.

    Darren.

  • andrewhnovak@gmail.comandrewhnovak@gmail.com Member, PRO Posts: 77

    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.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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.

  • andrewhnovak@gmail.comandrewhnovak@gmail.com Member, PRO Posts: 77
    edited March 2014


    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?

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    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.

  • andrewhnovak@gmail.comandrewhnovak@gmail.com Member, PRO Posts: 77

    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

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    You're welcome! :)

Sign In or Register to comment.