Im using Box2d and CCBox2d (an obj c wrapper for box2d), but the basic box2d logic would still be able to be able to be applied to my project. Anyway im moving a sprite around and I want the sprite to face the direction in which it is heading towards. I also want the rotation of the sprite to be as smooth as possible because this is key to my gameplay.
I have tried to move to this direction by using transform but i want the movement to be smooth and i would much rather use angular velocity.
I have tried doing the following but the sprite doesn't stop once it has reached the angle.
Thanks i would really appreciate any help.
Code: Select all
//This finds the angle to which direction the sprite is heading
rotationAngle = CC_RADIANS_TO_DEGREES(atan2(player.velocity.x, player.velocity.y));I have tried to move to this direction by using transform but i want the movement to be smooth and i would much rather use angular velocity.
I have tried doing the following but the sprite doesn't stop once it has reached the angle.
Code: Select all
player.angularVelocity = (rotationAngle - player.rotation) * 4;Thanks i would really appreciate any help.