Good morning,
Thank you for your answer, I’m going to look up what you just suggested. I’m already having a collision function and it’s set for every object that I have on my game.lua file
–Collision function
function onCollision(event)
if event.phase == “began” then
storyboard.gotoScene(“restart”, “fade”, 400)
end
end
Here is my object code:
ball = display.newImage(“ball.png”)
ball.x = 100; ball.y = 100
physics.addBody(ball, “dynamic”, {density=.05, bounce=0.1, friction=.2, radius=12})
screenGroup:insert(ball)
-----Obstacles code :
obst1 = display.newImage(“obst1.png”)
obst1.x = 640; obst1.y = -500
obst1.speed = 2
physics.addBody(obst1, “static”, {friction=0.5, bounce=0.3, density=.1 })
screenGroup:insert(obst1)
missile1 = display.newImage(“missile.png”)
missile1.x = 700; missile1.y = math.random(5,1090)
missile1.speed = math.random(2,6)
missile1.initY = missile1.y
missile1.amp = math.random(20,100)
physics.addBody(missile1, “static”, {density=0.1, bounce=0.1, friction=.2, radius=12})
screenGroup:insert(missile1)
missile1.angle = math.random(20,100)
So how can I make the ball collide with another object and start a sound without stopping the game ( on the collision function, the minute the object collides it goes to the restart screen)
Thank you so much …