krempler
krempler

Reputation: 11

Using audio_play_sound() in a if statement GameMaker

I am trying to use the command:

audio_play_sound()

I am trying to insert it into this piece of code, so that when the player jumps, a sound plays.

if (key_jump) && (jumps > 0)
{
     jumps -=1;
     vsp = -jumpspeed;
}

Code that causes problem:

if (key_jump) && (jumps > 0)
{
     jumps -=1;
     vsp = -jumpspeed;
     audio_play_sound(snd_jump)
}

Simply inserting the line into the if statement does not work, and gives the error WRONG NUMBER OF ARGUMENTS IN FUNCTION. This is rather confusing, perhaps I am using the wrong command? Thanks in advance

Upvotes: 0

Views: 548

Answers (2)

Jonathan Greene
Jonathan Greene

Reputation: 23

As the person above states your answer is audio_play_sound(snd_jump, 1, false).

Upvotes: 0

Andrew G.
Andrew G.

Reputation: 418

The problem is stated in the error, you're providing the wrong number of arguments to the audo_play_sound function.

from the docs

audio_play_sound(index, priority, loop);

Upvotes: 1

Related Questions