• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Question about where to place sound for.... [solved]

W

Wintermute()

Guest
Hi GMS'ers,

I have a weird problem today....

I have my player pickups being counted and displayed via a variable. I have a step event watching the pickups variable, and when it hits a certain number of pickups, it creates a level warp on-screen for the player to use.

My issue is I want to have a sound playing/looped when the the level warp is created. (you know a sorta warpy sound) Naturally I can't put the sound in the step event of the pickup watcher. But also, I tried to put the level warp sound in the level warp object's create event, but I still get the same problem (game locks up cause of creating bulk sound events)

Where can I put the sound, so it sits outside the step event that is kicking off the creating of the level warp object ? I'm thinking this is a chicken/egg, horse before cart type of question :)

Thank you...
 

TheouAegis

Member
You create the sound when the warp is created. It can be in the step event, just make sure the condition is set to create it only once.

Are you creating the warp every single step? No. So create the sound at the same time that you initiate the warp appearing.


.... wait,

I tried to put the level warp sound in the level warp object's create event, but I still get the same problem (game locks up cause of creating bulk sound events)
How is that causing bulk sound effects? What exactly is your code? You're doing something very wrong somewhere.
 

Carolusclen

Member
i find that using either a variable to check if the sound is playing or use an alarm helps

for the first, do something like this

create event
Code:
sound_playing = 0
step event
Code:
if (sound_playing = 0)
{
    /*play the sound code*/
    sound_playing = 1 // this sets it so the step event doesnt run the code again
}
wherever you have the code that stops the sound, or the object that plays the sound is deleted, just make sure you reset the sound_playing variable back to 0

:)
 
W

Wintermute()

Guest
i find that using either a variable to check if the sound is playing or use an alarm helps

for the first, do something like this

create event
Code:
sound_playing = 0
step event
Code:
if (sound_playing = 0)
{
    /*play the sound code*/
    sound_playing = 1 // this sets it so the step event doesnt run the code again
}
wherever you have the code that stops the sound, or the object that plays the sound is deleted, just make sure you reset the sound_playing variable back to 0

:)
Thank you, adding a check that the sound was not playing first, before adding the line in to create the sound, and the problem is solved and works perfectly.

Lovely warpy sound now.... :)
 
Top