SKCameraNode Scrolling Very Glitchy

When I scroll through on this scene with my code, it is extremely glitchy looking. Everything kind of jumps around very quickly until you let go. Is there a better way of doing this?


    var lastTouch: CGPoint!
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch : UITouch = touches.first!
        lastTouch = touch.locationInNode(self)
    }
    override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch : UITouch = touches.first!
        let touchLocation : CGPoint = touch .locationInNode(self)
        self.camera!.position = CGPointMake(self.camera!.position.x + (lastTouch!.x - touchLocation.x), self.camera!.position.y + (lastTouch!.y - touchLocation.y))
        lastTouch = touchLocation;
    }
    override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
        let touch : UITouch = touches.first!
        let touchLocation : CGPoint = touch .locationInNode(self)
        self.camera!.position = CGPointMake(self.camera!.position.x + (lastTouch!.x - touchLocation.x), self.camera!.position.y + (lastTouch!.y - touchLocation.y))
        print(touches.count)
        lastTouch = touchLocation;
    }


Here is a video of the glitchiness: https://vid.me/glEZ Is this just a bug with SKCameraNode as it is so new? If anyone knows what I am doing wrong I'd love to hear. Thanks!

I'm noticing a similar issue using a different implementation.


[Edit: removing link to gif because comment won't pass moderation -- see reply below for gif of this problem]


Recreate by:


1. Add children to SKCameraNode. (i.e.: high score). In the gif above, the bottom bar, the shields, and then settings icon are all children.

2. Add SKConstraint to the camera representing screen edges.

3. Add pan gesture recognizer with following code on change event:


    func handlePanChanged(recognizer:UIPanGestureRecognizer, target:SKCameraNode) {
        let translation = recognizer.translationInView(self.view!)
        let newPosition = CGPoint(x:target.position.x - translation.x, y:target.position.y + translation.y)
        target.position = newPosition
        recognizer.setTranslation(CGPointZero, inView: self.view!)
    }


Then, whenever you hit a screen edge, the camera glitches all of its children. Has anyone had success implementing this?


[Edit 2: Any quick movement will cause the glitch -- not just screen edges. So, that narrows my problem down to a camera with children nodes]

I know in the past I've dealt with something like this for my TD game. I ended up making a crazy virtual finger tracking system, maybe I should make that available on github. I would look at logging the X/Y positions that are coming back from touches and see whats going on. Maybe set a CGPoint to 0,0 and update that value as you move and see if its smooth. If it's jumping around you would need to look at the finger points and see what happened.

Example from the comment above:


http://gfycat.com/DimDeliciousDamselfly

[Update] Significantly improved as of beta 5. Still one edge case, but double checking to see if it is my code or not.

SKCameraNode Scrolling Very Glitchy
 
 
Q