Looking through the physics samples I noticed the enterFrame function seems to ensure that the location and rotation of a sprite matches its physics body. Instead of using gravity and/or linearVelocity I've been using Gtween to move my objects and I can still use the Enterframe but in this case to do the opposite - set a body to match its sprite - but only with the location.
Is there a way to set the rotation of a body based on the rotation of the sprite?
Sprite's have a setRotation but a body does not. A body DOES have a getAngle but doesn't have a setAngle.
At the moment I'm thinking I'll have to destroy the body and then re-create it inside the enterFrame, setting the updated angle in the createBody call.
Is there another way of doing this?
Comments
b2.Body has the function setAngle (in radians). Sorry, it's just missing in the reference manual. You can use setAngle without any problem.
I'm using v2011.9 beta3
EDIT: Just saw the link to beta7 and the above works fine