Tutorial FXGL Game Engine - getAudioPlayer(), playSound() with Example

Michael

Administrator
Staff member
  • Thread starter
  • Admin
  • #1
Hello there,
when you writing your first game you will notice that there is a really fancy play() method to play sounds.

However if you want to play a sound and stop it, you will have to add some more code. Here is an working example:

JavaScript:
Sound winSound = getAssetLoader().loadSound("sound.wav"); //loads and assigns the sound
getAudioPlayer().playSound(winSound); //plays the sound

// some other code

getAudioPlayer().stopSound(winSound); //stops the sound
 
Top