invisibloom invisibloom - 4 months ago 22x
Objective-C Question

SKSpriteNode zrotation M_PI is infuriating

so all i want to do is rotate an

by 90 degrees. just that. It should be simple yet my first approach, assuming it would be degrees, turns the object in completely the wrong diection. so i head to google > stackoverflow. plenty of answers to do with this, okay so ill try using
or some variation. nope. 'Double' is not convertible to 'CGFloat'. google again. "Try using skaction with blah blah" nope.

how difficult can it be to rotate a sprite? or am i insane


I'm assuming you're using Swift based on your "'Double' is not convertible..." comment.

The following rotates a sprite 90 degree counterclockwise:

        sprite.runAction(SKAction.rotateByAngle(CGFloat(M_PI_2), duration: 1.0))

The following rotates a sprite 90 degree clockwise:

        sprite.runAction(SKAction.rotateByAngle(CGFloat(-M_PI_2), duration: 1.0))