Skip to content

Instantly share code, notes, and snippets.

@akio0911
Created June 17, 2009 03:24
Show Gist options
  • Save akio0911/131059 to your computer and use it in GitHub Desktop.
Save akio0911/131059 to your computer and use it in GitHub Desktop.
// @interface MyLayer : Layer
- (BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView: [touch view]];
touchLocation = [[Director sharedDirector] convertCoordinate: touchLocation];
CGPoint location = ccp(touchLocation.x, touchLocation.y);
CGRect rect = CGRectMake(self.position.x - SIZE / 2, self.position.y - SIZE / 2, SIZE, SIZE);
if(CGRectContainsPoint(rect, location)){
// タップされた時の処理をここに書く
return kEventHandled;
}else{
return kEventIgnored;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment