好吧,标题暴露了问题,我如何将缓动应用于 SpriteKit 中的 SKAction 节点 Action ?
我发现这行得通:
SKAction *moveAction = [SKAction moveByX:moveX y:moveY duration:0.5];
moveAction.timingMode = SKActionTimingEaseInEaseOut;
[node runAction:moveAction];
然而,只有少数缓动类型可用 there ,即Linear、EaseIn、EaseOut、EaseInOut。
而且这些缓和值是固定的,不能更改。我正在寻找类似 EleasticInOut 的东西。最好有更多的控制。我该如何创建它?
最佳答案
我一直在使用 SKEase 框架: https://github.com/buddingmonkey/SpriteKit-Easing 它与标准 SpriteKit Action 一样简单易用,并添加了所有常见的更复杂的缓动、立方体、弹跳、弹性、后退等。 SpriteKitUtils 还添加了更复杂的缓动类型和一些方便的 SpriteKit 实用程序:https://github.com/raywenderlich/SKTUtils
另一种选择是使用自定义操作方法来滚动您自己的方法,并使用您的自定义缓动/动画功能将代码块传递给它:
-(SKAction *)customActionWithDuration:(NSTimeInterval)seconds actionBlock:(void (^)(SKNode *node, CGFloat elapsedTime))block
关于ios - SpriteKit SKAction 缓动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19095390/