I have a game where circular objects shoot up from the bottom of the screen and I would like to be able to swipe them to flick them in the direction of my swipe. My issue is, I don't know how to calculate the vector/direction of the swipe in order to get the circular object to get flicked in the proper direction with the proper velocity.
The static vector "(5,5)" I am using needs to be calculated by the swipe speed and direction of the swipe. Also, I need to make sure that once I make first contact with the object, it no longer happens, as to refrain from double hitting the object. Here's what I am doing currently:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
CGPoint location = [touch locationInNode:self];
SKNode* node = [self nodeAtPoint:location];
[node.physicsBody applyImpulse:CGVectorMake(5, 5) atPoint:location];
}
}