I am trying to create a function that if the user taps one ball it disappears and if the other one is also tapped , the user goes to the next level . But it’s complicated because I don’t know what to do
-- create image of a ball Ball1 = display.newCircle(100, 100, 10) physics.addBody(Ball1, "dynamic", {friction=2}) Ball1:applyLinearImpulse(-.05, .05, 0, 0) screenGroup:insert(Ball1) -- create image of a ball Ball2 = display.newCircle(100, 100, 10) physics.addBody(Ball2, "dynamic", {friction=2}) Ball2:applyLinearImpulse(-.05, .05, 0, 0) screenGroup:insert(Ball2)
functions
function onBallTap( event ) Ball1 = remove.self() Ball1 = nil end function onBallTap( event ) Ball2 = remove.self() Ball2 = nil end function scene:enterScene(event) Ball1:addEventListener( "tap", onBallTap ) Ball2:addEventListener( "tap", onBallTap ) end function scene:exitScene(event) display.remove(Ball) Ball1:removeEventListener( "tap", onBallTap ) Ball2:removeEventListener( "tap", onBallTap ) end