SpriteKit-Spring
SpriteKit-Spring copied to clipboard
Calculate distance correctly for animations using byValue
Hey! Awesome library, thanks for building it. I noticed that there's a bug with animations that use byValue
, e.g.:
SKAction.scale(by:duration:delay:usingSpringWithDamping:initialSpringVelocity:)
The distance isn't calculated correctly, so the behavior uses byValue
as the distance.
For example, say there's a node with a current scale of 1.0 - if we tried to scale it by 1.2, SpriteKit-Spring will currently scale it to 1.0 + 1.2
instead of 1.0 * 1.2
, which in this case would more than double the scale instead of scaling appropariately. I put up an example app at https://github.com/noahsark769/NGSpriteKitSpringTest to demonstrate this.
The fix is to calculate the initialDistance
based on multiplying it by initialValue
.
Let me know if I need to do anything else to fix this bug! Thanks!
@ataugeron bump! Would be awesome to get this out and pushed as a new version of the cocoapod 👍