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

coc*_*ner 0 iphone math velocity rotation cocos2d-iphone

我有这个:

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?
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

Jim*_*ler 6

float angle = atan2f(vel.y, vel.x);
Run Code Online (Sandbox Code Playgroud)