Reputation: 1108
I have a SKSpriteNode which scales up and down in a game. Every time the user taps on the screen, this code runs:
[self.sprite removeAllActions];
[self.sprite setScale:1];
SKAction *action = [SKAction scaleBy:scale duration:4];
[self.sprite runAction:action withKey:@"blowup"];
On the first tap it runs with the normal duration of 4 seconds however on the second and all further taps, the SKAction runs at 10 times the speed which is very unexpected as the only SKAction is this one called on the sprite and no other duration is used.
Any ideas? Thanks in advance
EDIT:
Changed my code to scaleTo
instead of scaleBy
However now I have found that if the user taps after the SKAction animation has finished then the expected animation time is played but if the user taps during the animation and tries to stop it then the super fast animation happens.
Upvotes: 0
Views: 69
Reputation: 8130
youre multiplying the scale each time you touch the sprite.
so lets say you scale by 4, the the next time you tap youre scaling the sprite by 16, the third time by 64. The sprite is going to be growing very quickly! You may want to consider ScaleTo
instead of ScaleBy
Depends on what you're going for..
Upvotes: 0