close

I suggest that you follow Sprite Kit’s coordinate and rotation conventions. Specifically, your sprite image should be facing right at zero degrees (the default value), and a positive value is a counter-clockwise rotation. That said, here's one way to apply an impulse in the direction a sprite is facing:

// Specify the force to apply to the SKPhysicsBody
CGFloat r =5;

// Create a vector in the direction the sprite is facing
CGFloat dx = r * cos (sprite.zRotation);
CGFloat dy = r * sin (sprite.zRotation);

// Apply impulse to physics body

[sprite.physicsBody applyImpulse:CGVectorMake(dx,dy)];
arrow
arrow
    全站熱搜

    pcwiki 發表在 痞客邦 留言(0) 人氣()