Hi guys I’m experimenting some issues trying to play 3 sounds on local collision listener.
Here is the code:
local function onLocalCollision( self, event ) if ( event.phase == "began" ) then print( "ball bouncing everywhere" ) audio.play(bounce) --this play the sound on every collision\*\*\* if (self.id == "ball" and event.other.id == "win") then print("ball and win rect collision") if goNext == false then goNext = true event.contact.bounce = 0 ball.fill = loads.winBall --\*\*\*I WANT TO PLAYA DIFFERENT AUDIO HERE BUT I CAN'T STOP THE BOUNCE AUDIO\*\*\* tmr1 = timer.performWithDelay(1, jointObjects) tmr2 = timer.performWithDelay(1000, levelCompleted) tmr3 = timer.performWithDelay(3000, nextLevel) end elseif self.id == "ball" and event.other.id == "lost" then print("ball and up wall collision") if goReload == false then goReload = true event.contact.bounce = 0 ball.fill = loads.lostBall --\*\*\*I WANT TO PLAY A DIFFERENT AUDIO HERE TOO\*\*\* tmr4 = timer.performWithDelay(1000, reloadLevel) end end end end
The thing is I have 4 wall on screen borders but the one on top is the lost id in the collision listener, so I want to play a “crash ball” sound when the ball hit that wall, and I want to play a “win sound” when the ball hit the rectangle with the id “win”
I try:
if (self.id == "ball" and event.other.id == "leftWall") or (self.id == "ball" and event.other.id == "rightWall") or (self.id == "ball" and event.other.id == "bottomWall") then audio.play( bounce ) end
but if I make the “walls” comparision no function trigger when “ball” hit “win”
Thank in advance
DoDi