Hi,
I am very famaliar with the sound api but I am struggling to implement something.
-
I have a ship that fires a laser
-
the laser has a sound
-
I have an enemy that has an explosion sound
all pretty standard stuff so far
-
the laser sound plays when fired
-
when the laser hits the enemy the explosion sound plays.
Now the laser can fire radily and each one has a laser sound.
I need to stop the laser sound when it hits the enemy.
SOunds simple but no.
I have to use a channel to stop the audio i,e, audio.stop(channel number)
But when I do this it stops ALL the laser sounds in play which is no good.
I tried assigning channels in a table and then removing them through a loop in the collision code…it had varied results but not successful.
Anybody know how I can achieve this ? stop the sound of the collided lazer only.
thanks
this is what i was trying but couldnt get it working properly:
lazerSoundHandles ={} lazerSounds ={7,8,9,10,11,12,13,14,15,16,17 } lazerSound = audio.loadSound("sounds/sfx/lazer.wav") function fire() lazerSoundHandle = audio.play(lazerSound,{channel = lazerSounds,loops = 0}) lazerSoundHandles[lazerSoundHandle] = lazerSoundHandle end function lazer :collision for k, v in pairs(lazerSoundHandles) do audio.stop(v) end