The problem is that the calculation for the final CGPoint
is based on where the UIPanGestureRecognizer
was added. In this case it has to be added to the SKView as an SKSpriteNode
is not a UIView
subclass so cannot have a UIPanGestureRecognizer
added to it.
Here's the old calculation as above
CGPoint finalPoint =
CGPointMake(recognizer.view.center.x + (velocity.x * slideFactor),
recognizer.view.center.y - (velocity.y * slideFactor));
Here's the change made to use the centre of the sprite node as the base for the calculation.
CGPoint finalPoint =
CGPointMake(touchedSprite.position.x
+ (touchedSprite.size.width / 2)
+ (velocity.x * slideFactor),
touchedNode.position.y
+ (touchedNode.size.height / 2)
- (velocity.y * slideFactor));