I just wonder about something. Im making a game and the music start playing when the game starts because it is on the "On start of layout" event. But when I die, and press play again. That restarts the layout so the music restarts. How do I fix that? (Music restarting when im pressing play again).
Thanks for your help.
Use a global variable to indicate whether you've already started playing the music, and only play it on startup if it's not already playing.
You have set the music to start on the start of layout, if you restart the layout it fires start of layout again. So you coded it to do exactly what it is doing. Ashley's solution should get you the rest of the way there.
I had the same issue. I added another event to stop playing music and then start playing music on start of layout.
Works for now. Not sure how the global variable thing works.
I think you could also use "Audio>Is tag playing", maybe, and if it's not playing, then start it. I might be wrong about that though...
Develop games in your browser. Powerful, performant & highly capable.
Thanks for your replies, but I dont understand the global variable thing. And what if im switching layout without stopping music, when I switch back the music will restart. How do I fix that?
<img src="https://dl.dropboxusercontent.com/u/50465867/Construct/Audio.jpg" border="0" />