• 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!

Pausing and resuming a 3d sound

In my 2d strategy game i use a lot of 3d sounds using emitters, and they work just fine. Mostly, it means an object plays a sound once, or an object plays a sound and is then destroyed. Often my code is as follows,

Create:
emitter_id = audio_emitter_create();
audio_play_sound_on(emitter_id,heavywind,true,1);

Step:
audio_emitter_position(emitter_id,x,y,0);

Destroy:
audio_emitter_free(emitter_id);

However, i'd like to have some sounds continuous that for example the player's units make, like horses galloping, but I can't make the 3d sounds pause when the unit stops and continue again when it moves. The sound never stops when the character does, and it just keeps stacking the sound when the character resumes movement...

Create:
emitter_id = audio_emitter_create();

Step:
audio_emitter_position(emitter_id,x,y,0);

if speed > 0
{
emitter_id = audio_emitter_create(); //to recreate the sound when unit is moving
audio_play_sound_on(emitter_id,gallop,0,1)
}
if speed = 0
{
audio_emitter_free(emitter_id);
}

Any clues what im doing wrong here?
P.s. can someone tip me how to put these codes into the form everyone prefers on the forums here...
Thanks beforehand!
 

GMWolf

aka fel666
Care to explain what the problem was and how you solved it? For the sake of future generations...
 
Care to explain what the problem was and how you solved it? For the sake of future generations...
I used this code i found on the forums on the topic: (altered here a bit)


Step event:

var moving

if moving
{
count += 1;
if (count == 13)
{
count = 0;
audio_play_sound_on(emitter_id,gallop,0,0);
bl=instance_create(x,y,obj_footprints)
bl.direction=direction
bl.image_angle=direction
}
}
else
{
count = 0;
}
 
Top