Reputation: 3266
I am executing the following SpriteKit action:
SKAction *moveLeft = [SKAction moveByX:-moveX y:0 duration:moveDuration];
SKAction *moveRight = [moveLeft reversedAction];
SKAction *sequence = [SKAction sequence:@[moveLeft, moveRight]];
[my_node runAction [SKAction repeatActionForever:sequence]];
I want to slow down the action for few seconds (this happens as a result of a user tap), and after that return to the normal speed. I have tried to do so by using
[my_node runAction [SKAction speedTo: 0.5 duration: 10]];
But it didn't work (the node halts for this duration instead of slowing down). Since the object is moving forever, I am not able to remove the action and replace with another one (since it is in the middle of its path) .
Any ideas how to execute this properly?
Upvotes: 2
Views: 1162
Reputation: 11878
Accepted answer doesn't work for me. My solution is to stop current animation and run it again with needed speed:
removeAllActions()
sequence.speed = 100 // run 100 times faster
run(anim)
Upvotes: 0
Reputation: 64477
Make sequence an ivar or property. Then at any time you can do this to slow it down:
sequence.speed = 0.5;
Upvotes: 7