简体   繁体   English

SKAction持续时间不正确

[英]SKAction incorrect duration appear

I have a SKSpriteNode which scales up and down in a game. 我有一个SKSpriteNode,可以在游戏中上下缩放。 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. 在第一次轻击时,它以正常的4秒持续时间运行,但是在第二次及随后的所有轻击中,SKAction的运行速度是其10倍,这是非常意外的,因为唯一的SKAction是在精灵上调用的,而没有其他持续时间用过的。

Any ideas? 有任何想法吗? Thanks in advance 提前致谢

EDIT: 编辑:

Changed my code to scaleTo instead of scaleBy 将我的代码更改为scaleTo而不是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. 但是,现在我发现,如果用户在SKAction动画完成后轻击,则会播放预期的动画时间,但是如果用户在动画期间轻击并尝试停止动画,则会发生超快动画。

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! 因此,假设您将比例缩放4,下次点击时将精灵按比例缩放16,将第三次按64缩放。精灵将快速增长! You may want to consider ScaleTo instead of ScaleBy 您可能需要考虑ScaleTo而不是ScaleBy

Depends on what you're going for.. 取决于您要干什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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