Thanks, ive rearranged the code and it works fine in the simulator, however it doesnt work when I try it on the device. Why is this? here is the code:
ball.myName = "ball"
flagpole.myName = "flag"
ball:addEventListener("collision", ball)
local function onComplete( event )
if event.action == "clicked" then
if event.index == 1 then
director:changeScene ("go2")
elseif event.index == 2 then
director:changeScene ("menu")
end
end
end
function ball:collision (event)
if event.other.myName == "flag" then
physics.pause()
transition.to(ball, {x = flagpole.x - 30, y = flagpole.y + 20})
local alert = native.showAlert( "Congratulations!", "You have completed level 1.",
{ "Next Level", "Menu" }, onComplete )
end
end
[import]uid: 116264 topic_id: 20348 reply_id: 80150[/import]