So I’m trying to make an object move the same way i move my finger on the screen. For example if i have an object in position x = 150 and y = 150 and then i touch the screen at x = 250 and y = 250. If i move my finger 30px to the right and 20px up( so now my finger is at x = 280 and y = 270) i want the object to move 30px to the right and 20px up( x= 180, y=170) so i want the object to move the same amount of px I move my finger. I’m able to do this with :
function screenTouch( event ) if event.phase == "began" then elseif event.phase == "moved" then elseif event.phase == "ended" then newX = (event.x - event.xStart) Ship.x = Ship.x + newX newY = (event.y - event.yStart) Ship.y = Ship.y + newY end end
But the object position is being updated only when I released my finger. If there any way I can do this on the “moved” phase? I want the object position to be constantly updated as i move my finger around. I tried putting the same code i have in the “ended” phase in the “moved” phase but it act very strange and the object moves really fast,