【问题标题】:How to get Angle of velocity to rotate a bullet?如何获得旋转子弹的速度角?
【发布时间】:2011-04-20 11:01:42
【问题描述】:

我有这个:

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?

有什么帮助吗?

【问题讨论】:

    标签: iphone math cocos2d-iphone rotation velocity


    【解决方案1】:
    float angle = atan2f(vel.y, vel.x);
    

    【讨论】:

    • 感谢工作,但我需要这样做:sp.rotation = CC_RADIANS_TO_DEGREES(-1*angle);
    • 是的,我可能应该解释一下,这会给你一个弧度(0.. pi*2)而不是度数(0.. 360)的结果
    猜你喜欢
    • 2013-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-20
    • 1970-01-01
    • 2016-11-22
    • 2013-01-28
    • 1970-01-01
    相关资源
    最近更新 更多