Reputation: 792
I made a sprite to stand on the ground, but i would want the sprite to rotate to face the ground, so that it would look like he is crawling on the ground instead.
func setUpRunner() {
let runnerSize = CGSizeMake(15, 40)
Runner = SKShapeNode(rectOfSize: runnerSize)
Runner.fillColor = SKColor.blackColor()
Runner.name = self.rName
Runner.physicsBody = SKPhysicsBody(rectangleOfSize: runnerSize)
Runner.physicsBody.dynamic = true
Runner.physicsBody.affectedByGravity = true
Runner.physicsBody.allowsRotation = false
Runner.physicsBody.restitution = 0.0
Runner.physicsBody.categoryBitMask = rCategory
Runner.physicsBody.contactTestBitMask = groundCategory
Runner.position = CGPointMake(20, self.frame.height/3)
self.addChild(Runner)
}
func crouch() {
Runner.zRotation = 90 //or -90
}
But this would make him face either North-East, North-West.
Upvotes: 0
Views: 579
Reputation: 11868
Have a look at the API of SKNode. It says
zRotation
The Euler rotation about the z axis (in radians).
This means 360 degrees are 2*M_PI
and thus 90 degrees are M_PI/2
Upvotes: 1