我想在另一个人开始播放时停止发声。
if (event.object1.myName == "obst3") then
audio.play(colsound)
如果下一个开始,我希望这个停止。
if (event.object1.myName == "t") then
audio.play(explosion)
另外,我需要知道如何只发射一次声音(当我的物体与墙壁发生碰撞时,声音突然出现,即使玩家再次接触墙壁,我也需要听到一次声音。
答案 0 :(得分:2)
播放具有参考ID值的每个音频:
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