have object follow event without transition.to

what would be a good alternative for transition.to, like is there a way to make the object follow wherever you touch, maybe changing physics to go towards the event??, Thank you!! [import]uid: 38977 topic_id: 20680 reply_id: 320680[/import]

try using a runtime touch and enterFrame event
touch for determining the touch location
enterFrame for moving the object
here’s an example, assuming you already have a display object named “object”:

local target = { x=0, y=0 }  
function move( event )  
 if( target.x ~= 0 and target.y ~= 0 ) then  
 angle = math.atan2( object.y - target.y, object.x - target.x )  
 angle = ( angle \* 3.14159265358 ) / 180  
 angleInRadians = (angle \* PIE)/180  
  
 distance = 3  
  
 deltaX = ( mCos( angleInRadians ) \* distance )  
 deltaY = ( mSin( angleInRadians ) \* distance )  
  
 object:translate( 0 - deltaX, 0 - deltaY )  
 end  
end  
  
function location( event )  
 if( event.phase == "ended" or event.phase == "cancelled" ) then  
 target.x = event.x  
 target.y = event.y  
 end  
 return true;  
end  
  
Runtime:addEventListener( "enterFrame", move )  
Runtime:addEventListener( "touch", location )  
  

I derived this from my working code, so I think this will work :smiley:
You can fix the code for the physics part [import]uid: 71085 topic_id: 20680 reply_id: 83515[/import]