Hi. I’m eleven years old and a novice at Corona. This may be relevant to the current topic (having balls shoot in the correct direction).
I created a cannonBall and a cannon and made them a single group and put them in the same place. I created a working method of rotating the cannon via touch:
local function rotateTo (event)
local deg = math.atan2( event.y - cannonGroup.y, event.x - cannonGroup.x )
cannonGroup.rotation = math.deg(deg)
end
However, after creating a shootBall function (using the code given kindly by indiegamepod) and applying it and the rotateTo function to a turnAndShoot function:
local function turnAndShoot (event)
if ( event.phase == “began” ) then
timer.performWithDelay( 1, rotateTo, 0 )
end
if ( event.phase == “ended” ) then
timer.performWithDelay( 1, shootBall )
end
end
the cannon will rotate with the touch perfectly, but the shootBall function will not call. Why is this? [import]uid: 82408 topic_id: 15607 reply_id: 315607[/import]