ios - Sprite Kit - Rotate to face the ground -
ios - Sprite Kit - Rotate to face the ground -
i made sprite stand on ground, want sprite rotate face ground, crawling on ground instead.
func setuprunner() { allow 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 create him face either north-east, north-west.
have @ api of sknode. says
zrotation euler rotation z axis (in radians).
this means 360 degrees 2*m_pi
, 90 degrees m_pi/2
ios sprite-kit swift
Comments
Post a Comment