Ho can i add a rotation to the object addition to the dragging ?
i dosen't have to be multi touch.
code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:self.view];
CGFloat dx = currentTouch.x - carMove.position.x;
CGFloat dy = currentTouch.y - carMove.position.y;
CGFloat dist = sqrt(dx * dx + dy * dy);
if(dist <carMove.radius) {
carMove.velocity = CGPointMake(0.0, 0.0);
carMove.dragging = YES;
}
lastTouch = currentTouch;
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
currentTouch = [touch locationInView:self.view];
if( carmove.dragging ){
carMove.position = currentTouch;
carMove.velocity = CGPointMake(currentTouch.x - lastTouch.x, currentTouch.y - lastTouch.y);
}
lastTouch = currentTouch;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
carMove.dragging = NO;
}