William Garrison
Member
Okay so simple enough I want a hover sound to play when the characters HSP (horizontal speed) is > 0. So if this is the case and its HSP > 0 then I set the hovering var to be true. Otherwise its false. Once hovering is true I do the following (hovering code included).
PLAYER - CREATE
PLAYER - STEP
SCRIPT
I set the hovering audio to not loop so I can test it. It sounds like its looping so that tells me its playing every step, which I dont want. I just want it to turn on ONCE play looped and the turn off when the HSP = 0.
PLAYER - CREATE
GML:
hovering = false;
GML:
if (!place_meeting(x, y + 1, allCollide))
{
sprite_index = sHero_jump
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
}
else
{
canjump = 10;
image_speed = 1;
if (hsp == 0)
{
sprite_index = sHero_idle;
hovering = false;
}
else
{
sprite_index = sHero_run;
hovering = true;
}
if (walksp == 5)
{
sprite_index = sHero_run;
hovering = true;
}
}
GML:
if (hovering) {
sc_playFX(sn_heroHover, 10, false);
} else {
audio_stop_sound(sn_heroHover);
}
GML:
var _playable = true;
if (_playable) {
audio_play_sound(argument0, argument1, argument2);
_playable = false;
} else {
_playable = true;
}