Reputation: 7
I want to stop a sound when another starts playing .
if (event.object1.myName == "obst3") then
audio.play(colsound)
I want this one to stop if the following one starts .
if (event.object1.myName == "t") then
audio.play(explosion)
Also, I need to know how to launch the sound just once ( when my objects collide with a wall, a sound pop out I need this one to be heard just once even if the player touches again the wall.
Upvotes: 0
Views: 98
Reputation: 94
Play every audio with reference id value :
if (event.object1.myName == "obst3") then
local isChannel1Playing = audio.isChannelPlaying( 2 )
if isChannel1Playing then
audio.stop( playLaserSound2 )
playLaserSound2 = nil
end
playLaserSound1 = audio.play(colsound, { channel=1 })
end
if (event.object1.myName == "t") then
local isChannel1Playing = audio.isChannelPlaying( 1 )
if isChannel1Playing then
audio.stop( playLaserSound1 )
playLaserSound1 = nil
end
playLaserSound2 = audio.play(explosion, { channel=2 })
end
Upvotes: 1