SpriteKit-Spring icon indicating copy to clipboard operation
SpriteKit-Spring copied to clipboard

Calculate distance correctly for animations using byValue

Open noahsark769 opened this issue 7 years ago • 1 comments

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!

noahsark769 avatar May 25 '17 04:05 noahsark769

@ataugeron bump! Would be awesome to get this out and pushed as a new version of the cocoapod 👍

noahsark769 avatar Aug 27 '17 19:08 noahsark769