Page 1 of 1

Listener when a body position is updated by World

Posted: Sat Sep 30, 2017 10:17 pm
by asantoso
I want to listen when World updates position of a body (due to physics). How to do this?
Thanks.

Re: Listener when a body position is updated by World

Posted: Wed Oct 04, 2017 8:55 pm
by William
Can you provide more details about what you would use the information for?

The reason I ask is that the physics engine may update a body's position every frame, so having that level of knowledge may not be sufficient to achieve your goal.

On a simple level, you could store the position of the body elsewhere in one frame and compare it to the body's position in the next frame.

If you are interested in when a body stops moving, then you can check its status each frame by calling the body.isAsleep method.

William

Re: Listener when a body position is updated by World

Posted: Thu Oct 12, 2017 1:03 am
by asantoso
I am overriding setAsleep method which works fine.