Jarron
Jarron

Reputation: 1049

Reduce Node Speed as it gets Closer to a Specific Point

When bringing a node into view, I don't like how it is travelling and then suddenly stops as it reaches it's moveTo point. What I would like to do is slowly reduce the speed of the node as it approaches it's moveTo point, but after 2 days of contemplating how I would achieve this, I have not figured out a solution (it is most likely very simple).

I have managed to increase and decrease a nodes speed gradually using a timer and moveBy (Not moveTo), but that does not stop the node at a specific point or if I tell it to stop once it reaches a specific point, the speed the node could be small or could be large.

Does anybody have an idea of how I might be able to solve my problem.

Upvotes: 1

Views: 76

Answers (1)

ABakerSmith
ABakerSmith

Reputation: 22939

You could set the timing mode of your action to EaseOut or EaseInEaseOut (The default is Linear). For example

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

From the SKAction documentation, other options include:

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.

Upvotes: 1

Related Questions