How do you check the distance your draggable object has travelled between frames?

I’m trying to detect when a person playing my game moves my player (a draggable object) too fast (ie. swipes it). The reason is, if my player is dragged fast enough, it can actually be made to pass right through the enemies in my game without registering a collision, allowing the person playing to cheat. As a work around (.isBullet isn’t working, in case that’s what you were about to suggest), I want to be able to sense when a super fast movement is made, and cause it to trigger some kind of “stop half-way” action. I figure the only way to be able to detect such a movement is to measure the distance the player has travelled from one frame to the next (the smallest possible unit of time measurement). However, I’m not sure how to code this. My player is your bog-standard draggable object:
--Player movement functionlocal function onTouch( event ) local player = event.target local phase = event.phase if "began" == phase then -- Make target the top-most object local parent = player.parent parent:insert( player ) display.getCurrentStage():setFocus( player ) player.isFocus = true -- Store initial position player.x0 = event.x - player.x player.y0 = event.y - player.y[/code]Any help or advice would be much appreciated.Thanks in advance,Steven [import]uid: 79394 topic_id: 16629 reply_id: 316629[/import]

What you would need to start the starting values of player and compare it to the ending value before the object moves. It’ll get kind of tricky as I can see having a lot of i statements to compare to. (Positive, negative, x, y, etc…)

I would add something like:

local playerstartx = player.x  
local playerstartx = player.y  
  
if (player.x - playerstartx) \>= (somenumber) then  
Stop your player and end your drag function.  
end  

[import]uid: 23649 topic_id: 16629 reply_id: 62109[/import]