Listener when a body position is updated by World

Posts that don't fit into other categories.
asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Listener when a body position is updated by World

Postby asantoso » Sat Sep 30, 2017 10:17 pm

I want to listen when World updates position of a body (due to physics). How to do this?
Thanks.

William
Site Admin
Posts: 349
Joined: Sat Feb 06, 2010 10:23 pm

Re: Listener when a body position is updated by World

Postby William » Wed Oct 04, 2017 8:55 pm

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

asantoso
Posts: 11
Joined: Thu Mar 02, 2017 12:18 am

Re: Listener when a body position is updated by World

Postby asantoso » Thu Oct 12, 2017 1:03 am

I am overriding setAsleep method which works fine.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest