ios - Swift / SpriteKit help: Increase CGFloat continuously to allow continuous rotation around a fixed point -
im making simple game apple's spritekit , swift , have encountered problem. im trying paddle node (paddle) rotate continuously around fixed node (anchornode) inside circle; however, cannot figure out how make paddle node (paddle) keep rotating around fixed point node (anchornode) because of constrains in skaction.rotatebyangle statement making end after amount of time / rotation.
any appreciated!
here code reference:
//setting anchor node anchornode.position = cgpointmake(cgrectgetmidx(self.frame), cgrectgetmidy(self.frame)) anchornode.size.height = (self.frame.size.height / 1000) anchornode.size.width = anchornode.size.height self.addchild(anchornode) //setting achor node's physucs anchornode.physicsbody = skphysicsbody(circleofradius: (circle.frame.size.height / 1000)) anchornode.physicsbody?.dynamic = false anchornode.physicsbody?.affectedbygravity = false anchornode.physicsbody?.friction = 0 //making anchor node rotate let rotate = skaction.rotatebyangle(cgfloat(3.14), duration: nstimeinterval(1.5)) anchornode.runaction(rotate) //setting paddle node paddle.position = cgpointmake((circle.frame.width / 2), 0) paddle.size.height = (self.frame.size.height / 50) paddle.size.width = (self.frame.size.width / 7) anchornode.addchild(paddle)
try adding code.
override func update(currenttime: nstimeinterval) { //how make spin let speed = cgfloat(5) let degreerotation = cdouble(speed) * m_pi / 180 paddle.zrotation -= cgfloat(degreerotation) }
Comments
Post a Comment