Timers and how to tell if an object stops moving?

Hello,
I’m new at Corona and got excellent help in my last topic. After trying to figure this out for myself for a while I wanted to ask.

How could I tell if an object stops moving? I looked into getlinearvelocity, and also event:speed, and I couldn’t get any to work. I wanted to stop something if an object hasn’t moved for a few seconds.

This leads me to the next thing. I’ve made an improvised timer, but it worked pretty sloppily.
Then there is timer.performWithDelay( delay, listener [, iterations] )

Does that make sense in this context? Could I call this, if an object stops moving for X seconds? I’d like it to also abort the “stopping”, once it starts moving. I think I could just use (cheap code) “if speed < number then initiate stopping” and it would stop if the speed would rise over “number”, no?

When I tried around with performWithDelay it seemed to be “unstoppable” though once initiated.

Which would be the most resourceful and practical solution to this?

Any help is appreciated, thanks! [import]uid: 65258 topic_id: 10884 reply_id: 310884[/import]

Assuming you are not checking for movements of lot of objects you can do following,
[lua]–assuming your defined object is called object1

local x0, y0

local function gameLoop(e)
if not(x0 == nil or y0 == nil) then
deltaX = object1.x - x0
deltaY = object1.y - y0
end
x0 = object1.x
y0 = object1.y

if deltaX == 0 and deltaY == 0 then
–The object has stopped moving.
–Call other function that needs to be called when object stops moving here.

end

end

Runtime:addEventListener(“enterFrame”,gameLoop)[/lua] [import]uid: 48521 topic_id: 10884 reply_id: 39558[/import]

Thanks, that works pretty well. Its the only object I check for movement right now.

Now I only need to learn about the timers, as asked in the first post. Could somebody give me a heads up with that too?

Thank you again for the great advice. [import]uid: 65258 topic_id: 10884 reply_id: 39609[/import]