开发者

How to get Angle of velocity to rotate a bullet?

开发者 https://www.devze.com 2023-02-27 01:30 出处:网络
I have this: CGPoint vel = hudLayer.rightJoystick.velocity; CCBullet* sp = [CCBullet spriteWithFile:@\"g开发者_JAVA技巧reen.png\"];

I have this:

CGPoint vel = hudLayer.rightJoystick.velocity;

            CCBullet* sp = [CCBullet spriteWithFile:@"g开发者_JAVA技巧reen.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?

Any help?


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号