I am using touches to set SpriteKit nodes in motion. Currently I do this:
//(previous code turns current touch and last touch into thisP and thatP)...
CGPoint velocity = CGPointMake(thisP.x - lastP.x, thisP.y - lastP.y);
//If the velocity is non-zero, apply it to the node:
if (!CGPointEqualToPoint(velocity, CGPointZero)) {
[[MyNode physicsBody] applyForce:CGVectorMake(velocity.x, velocity.y)];
}
This is very effective at getting the nodes to move different speeds depending on how fast the user swiped. Oh, Anna, if only that was what I wanted!
My actual desired effect is for every node to move at a uniform speed, no matter how fast they were swiped. It seems like I'd have to make some kind of calculation that removes magnitude from the vector but preserves direction, which is beyond me.
Is this possible?