I've read in a few placing that changing the speed
variable of an SKAction will change the speed; however, that doesn't seem to be working for me.
- (void)startAnimating {
SKAction *moveDown = [SKAction moveByX:0 y:-[CAUtilities screenSize].height duration:self.animationDuration];
[self setMoveDownAction:[SKAction repeatActionForever:moveDown]];
[self runAction:self.moveDownAction];
}
- (void)incAnimationSpeedBy:(CGFloat)aFloat {
self.moveDownAction.speed += 0.5;
NSLog(@"%f", self.moveDownAction.speed);
}
The actual value of self.moveDownAction.speed
changes as seen in the NSLog
call, but the actual animation doesn't change.
I have incAnimationSpeedBy:
being called when the screen is tapped, so using a SKAction
sequence with a runBlock
won't work for my needs.
I've tried:
moveDown
as an instance variable. duration
property rather than speed
. Any help is appreciated, thanks.
The problem was I was trying to change the speed on the different SKAction
objects when I should have been changing the speed on the parent SKSpriteNode
.
- (void)startAnimating {
SKAction *moveDown = [SKAction moveByX:0 y:-[CAUtilities screenSize].height duration:3.0];
[self runAction:[SKAction repeatActionForever:moveDown]];
}
- (void)incAnimationSpeedBy:(CGFloat)aFloat {
if (self.speed + aFloat < kMaxSpeed)
self.speed += aFloat;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.