I'm trying to drag the sprite along the y axis, but I’ll make the sprite a stick on the user's fingers, depending on where the strokes on the node started. The sprite is being dragged at the moment, but it seems to bind the sprite binding to the contact in the node.
Assuming this has something to do with getting the location inside the node by doing [touch locationInNode:selectedNode]; but I'm not sure where to go from there.
Here is my current code.
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { for (UITouch *touch in touches) { CGPoint location = [touch locationInNode:self]; SKNode *node = [self nodeAtPoint:location]; CGPoint newPosition = CGPointMake(node.position.x, location.y); if ([node.name isEqualToString:self.selectedNode] ) { if (newPosition.y > 230) { newPosition.y = 230; } node.position = newPosition; } } }
source share