According to the manual, each sound you play, requires you to assign a channel-handle when you play the sound:
In this example (from the manual), your sound will be playing through channel "chnDie".
Then you have two options:
- if an enemy shoots, you check if the channel is already playing (ChannelPlaying), and if not, play the sound through the channel
if the channel is already playing, do nothing (don't play the sound)
- if an enemy shoots, you check if the channel is already playing and if it is, stop the channel using StopChannel and play the sound
; Assign a global variable for the sound Global sndPlayerDie ; Load the sound file into memory sndPlayerDie=LoadSound("sounds/die.wav") ; Play the sound via channel chnDie chnDie=PlaySound ( sndPlayerDie )
In this example (from the manual), your sound will be playing through channel "chnDie".
Then you have two options:
- if an enemy shoots, you check if the channel is already playing (ChannelPlaying), and if not, play the sound through the channel
if the channel is already playing, do nothing (don't play the sound)
- if an enemy shoots, you check if the channel is already playing and if it is, stop the channel using StopChannel and play the sound