简体   繁体   中英

SKAction incorrect duration appear

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.

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..

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM