SKSpriteNode zrotation M_PI infuriates
so all I want to do is rotate SKSPriteNode
90 degrees. just that. It should be simple, but my first approach, assuming it will be a degree, completely turns the subject into a wrong diet. so I'm heading to google> stackoverflow. many answers to do with this good, so try to use M_PI
or some options. Nope. "Double" is not converted to "CGFloat". google again. "Try skaction with blah blah" nope.
How difficult is it to rotate a sprite? or am i crazy
source to share
I assume you are using Swift based on your comment "Double 'is not convertible ...".
The next rotation of the sprite is 90 degrees counterclockwise:
sprite.runAction(SKAction.rotateByAngle(CGFloat(M_PI_2), duration: 1.0))
The next rotation of the sprite is 90 degrees clockwise:
sprite.runAction(SKAction.rotateByAngle(CGFloat(-M_PI_2), duration: 1.0))
source to share
This seems to work fine for me. Understanding the transitions between radians and degrees is important. http://en.wikipedia.org/wiki/Radian#Conversion_between_radians_and_degrees
sprite.zRotation = CGFloat (M_PI_2)
source to share