在靠近特定点时降低节点速度

Reduce Node Speed as it gets Closer to a Specific Point

当我看到一个节点时,我不喜欢它的行进方式,然后在到达它的 moveTo 点时突然停止。我想做的是在节点接近它的 moveTo 点时慢慢降低节点的速度,但是在考虑了 2 天我将如何实现这一点之后,我还没有找到解决方案(这很可能非常简单)。

我已经设法使用计时器和 moveBy(不是 moveTo)逐渐增加和减少节点速度,但这不会在特定点停止节点,或者如果我告诉它一旦到达特定点就停止,节点的速度可小可大。

有没有人知道我可以如何解决我的问题。

您可以将动作的计时模式设置为EaseOutEaseInEaseOut(默认为Linear)。例如

let moveAction = ...
moveAction.timingMode = .EaseOut

来自SKAction documentation,其他选项包括:

Linear. Specifies linear pacing. Linear pacing causes an animation to occur evenly over its duration.

EaseIn. Specifies ease-in pacing. Ease-in pacing causes the animation to begin slowly and then speed up as it progresses.

EaseOut. Specifies ease-out pacing. Ease-out pacing causes the animation to begin quickly and then slow as it completes.

EaseInEaseOut. Specifies ease-in ease-out pacing. An ease-in ease-out animation begins slowly, accelerates through the middle of its duration, and then slows again before completing.