How to get Angle of velocity to rotate a bullet?

点点圈 提交于 2019-12-23 06:00:09

问题


I have this:

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?

Any help?


回答1:


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


来源:https://stackoverflow.com/questions/5729221/how-to-get-angle-of-velocity-to-rotate-a-bullet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!