1

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.

Jarron
  • 1,049
  • 2
  • 13
  • 29
  • As an addition to what ABakerSmith suggested (custom action is maybe most suitable solution) you can check https://github.com/warrenm/AHEasing and https://github.com/buddingmonkey/SpriteKit-Easing I've tried second one few days ago, and it worked nicely. – Whirlwind Jun 30 '15 at 15:39
  • Thanks Whirlwind, I will check this out also. – Jarron Jun 30 '15 at 16:17

1 Answers1

1

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.

ABakerSmith
  • 22,759
  • 9
  • 68
  • 78
  • This looks simpler then I expected, let me try this out now. Thanks – Jarron Jun 30 '15 at 14:43
  • This is great!!! I'll accept your answer shortly. Can the EaseOut be adjusted so that it's longer or shorter in length? I'm happy with what it produces, I'm just wondering. Thanks – Jarron Jun 30 '15 at 14:48
  • Glad I could help :) I don't believe that comes as standard, you may be interesting in http://stackoverflow.com/questions/19095390/spritekit-skaction-easing – ABakerSmith Jun 30 '15 at 14:50
  • Thanks, I'll look into the link you provided. – Jarron Jun 30 '15 at 14:54
  • There are some more eases there, but I'm not sure it gives you full control; could be something interesting to investigate... – ABakerSmith Jun 30 '15 at 14:57