Skip to content

Instantly share code, notes, and snippets.

@sash13
Created April 28, 2010 07:46
Show Gist options
  • Save sash13/381842 to your computer and use it in GitHub Desktop.
Save sash13/381842 to your computer and use it in GitHub Desktop.
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
mouse2 = cpMouseNew(space);
cpMouseGrab(mouse, cpv(location.x, location.y), 0);
}
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView: [myTouch view]];
location = [[CCDirector sharedDirector] convertToGL: location];
cpMouseMove(mouse, cpv(location.x, location.y));
if(mouse->body == nil){
cpMouseGrab(mouse, cpv(location.x, location.y), 0);
}
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
[self ccTouchesCancelled:touches withEvent:event];
}
- (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
cpMouseDestroy(mouse);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment