I tried to make a big asteroid and make it follow the ship everytime I change it location until it reaches it. I tried to modify the dragShip function but when I drag the ship, the asteroid just follow the initial position of the ship. Can you help me? I am on the starExplorer tutorial in Corona.
boss = display.newImageRect( mainGroup, objectSheet, 1, 102, 85 )
_ boss.myName = “boss” _
_ boss.x = display.contentCenterX _
boss.y = (display.contentCenterY)*0.5
_ boss.xScale = 2.5 _
_ boss.yScale = 2.5 _
function dragShip( event )
_ ship = event.target _
_ phase = event.phase _
if ( “began” == phase ) then
_ – Set touch focus on the ship _
display.currentStage:setFocus( ship )
_ – Store initial offset position _
_ ship.touchOffsetX = event.x - ship.x _
boss = transition.to( boss ,{ time=4000, x=ship.x, y=ship.y} )
elseif ( “moved” == phase ) then
_ – Move the ship to the new touch position _
_ ship.x = event.x - ship.touchOffsetX _
boss = transition.to( boss ,{ time=4000, x=ship.x, y=ship.y} )
elseif ( “ended” == phase or “cancelled” == phase ) then
_ – Release touch focus on the ship _
display.currentStage:setFocus( nil )
boss = transition.to( boss ,{ time=4000, x=ship.x, y=ship.y} )
_ end _
_ return true – Prevents touch propagation to underlying objects _
_ end _