如何获得旋转子弹的速度角?

时间:2011-04-20 11:01:42

标签: iphone math cocos2d-iphone rotation velocity

我有这个:

CGPoint vel = hudLayer.rightJoystick.velocity;

            CCBullet* sp = [CCBullet spriteWithFile:@"green.png"];
            sp.position = player.position;
            [self addChild:sp z:-10];

            vel = ccpMult(ccpNormalize(vel), 300);
sp.rotation = //how to get the rotation out of the velocity?

任何帮助?

1 个答案:

答案 0 :(得分:6)

float angle = atan2f(vel.y, vel.x);