How to play sounds when pausing/unpausing

Darkhog

  • Posts: 1243
Thanks to Epic's article in my upcoming game I have custom pause screen now. But that's not enough for me. I'd like to know how to play sounds when game is pausing and unpausing (I want to play two different sounds for it).


So how to do it? I'd like to achieve similar thing as Nintendo did with original Super Mario Bros.

There are no impossible things. There is only lack of skills.
Don't click this if your computer has less than 641 kilobytes of RAM.
Stencyl stencyling stencylish stencylers :D

Greg

  • *
  • Posts: 1260
You could check for a press of the "P" key and play a sound.  Just use a boolean to keep track of whether or not the game is paused, if you want two different sounds.

Hectate

  • *
  • Posts: 4645
Keep in mind that clicking outside of the window will pause it by default unless you've disabled that - which means that you could end up with the sounds playing at the wrong times that way.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Epic428

  • Posts: 1118
Your best bet would be to embed a sound the same way as you did custom sprites. Then you can use FlxSound.play() in the pause screen. That would at least work for when the pause screen displays. When it is killed, that is a different story.

Maybe later this week I will take a look into it a little further to see how the pause screen is created and destroyed. That will tell me the best way to add a sound to it.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs