coding22 coding22 - 2 years ago 62
Swift Question

How do I make my node rotate at a slower duration?

I have this node and when I press and hold a button I want the node to rotate slower. I changed the

parameter from 1 to 50 and it still rotates the node the same speed. What am I doing wrong?

let rotateRate = (SKAction.rotateByAngle(CGFloat(-M_PI_2), duration: 50.0))
let repeatRotate = SKAction.repeatActionForever(rotateRate)

Answer Source

Once you create an action, you can't modify its duration parameter... So you can't affect on speed of an action in the way you are expecting. But you have a few options:

  • to re-create the action (you probably want to run an action with key for this)

  • to change the speed of that action:

`if let action = node.actionForKey("aKey"){

   action.speed = 1.5


Probably some more, but this will give an idea what is going on.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download