I have a SKSpriteNode as a child of an SKScene, but the sprite node is much bigger than the scene, and I need the user to be able to manually scroll the sprite node around in order to see all of it (it is a giant map). I am using the SKAction moveByX: y: Duration: method and the moveByX part is working as expected. The move by Y pat though, causes the map to shoot off the bottom of the screen very fast. Here is my code in touchesMoved:
CGFloat xDiff = location.x - prevLocation.x;
CGFloat yDiff = location.y - prevLocation.y;
SKAction *moveBy = [SKAction moveByX:xDiff y:yDiff duration:0];
if (YES) NSLog(@"%f, %f", xDiff, yDiff);
[map runAction:moveBy];
So, this logic is spot on for the x axis but not so for the y axis. Furthermore, if I change the yDiff to be calculated in reverse (prevLocation.y - location.y) I notice in the NSLog output that the yDiff is cumulative in a single pan action, but the xDiff is not.
What am I missing?