Toggle points sound

Started by ddavey1983, Wed 22/07/2020 19:30:35

Previous topic - Next topic

ddavey1983

Apologies if this is covered elsewhere but if it is, I can’t find it.

Is there a simple way to toggle on/off the sound that plays when a player gets points?

I like the idea of having a points sound but after a while it can (does) get a bit irritating. I’d like to have it toggled by pressing a key if at all possible.

Anyone have any idea?

Thanks.

Khris

There's a global integer variable called  game.score_sound  which can be used to change the sound effect in-game. It's -1 by default (no sound), and setting the sound in the editor will set the variable to the index number of the sound.

To toggle the sound on or off, subtract 1 from the index of the sound you're using and insert it in place of the 4:
Code: ags
  // in on_key_press
  if (keycode == eKeyF10) game.score_sound = 4 - game.score_sound; // F10 toggles between 5 and -1

ddavey1983

Fantastic. Worked like a charm. Thank you very much!

SMF spam blocked by CleanTalk