Corona: How to detect the direction of an object with physics

advertisements

I would like to know how to detect the direction of an object with physics, I mean when is falling down. can it be by a eventListener? any idea how to do it?

I need it for know can I change the spriteSheet.

Thanks.


To find the exact angle based on an objects velocity you'd call:

 local angle = atan2(xVelocity, yVelocity)

This returns the angle in radians, which you can then convert to degrees. This allows for more precise control over the object. Daniel Shiffman wrote a great book involving many aspects of physics simulation over at http://natureofcode.com/book/.