I've been searching on the internet for several days, I didn't find what I'm looking for.
I'm working on an iOS game and I would like to move some sprites using usingSpringWithDamping (to have some rubber effect when moving my sprites).
I have found many solutions for UIViews but nothing for SKSpriteNode.
I would like to move a SKSpriteNode from position 1 to position 2 with a Damping effect.
Can you please give me some ideas? Thanks.
C.C.
The Sprite Kit Utils from Ray Wenderlich (https://github.com/raywenderlich/SKTUtils) could be what you are looking for. Specifically, using SKTEffects and SKTTimingFunctions will allow you to add easing to your SKActions.
For example SKTTimingFunctionElasticEaseIn, SKTTimingFunctionElasticEaseOut, and SKTTimingFunctionElasticEaseInOut have the rubber effect you are looking for, but you may need to tweak them to your needs. Ray's utils also have other easing functions available; there is a good reference on different easing functions at: http://easings.net
Hope this helps!
UIView animations have support for spring animations, but these are not available in SpriteKit.
There is a third-party library on GitHub which extends SKAction with spring animations: https://github.com/ataugeron/SpriteKit-Spring
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With