-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated code for cocos2d v. 0.99.4. Also added auto-registering/unreg…
…istering for touch events when a Node is entered/exited
- Loading branch information
Jeremy Flores
committed
Jul 22, 2010
1 parent
e18f52c
commit 6e5e8ae
Showing
341 changed files
with
52,585 additions
and
2,500 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CocosNode+Additions.h | ||
// OMGTTT | ||
// | ||
// Created by Jeremy on 12/18/09. | ||
// Copyright 2009 Jeremy Flores. All rights reserved. | ||
// | ||
|
||
|
||
#import "cocos2d.h" | ||
|
||
@interface CCNode (Additions) | ||
|
||
@property (nonatomic, readonly) CGRect rect; // dynamic | ||
@property (nonatomic, readonly) CGPoint center; // dynamic | ||
|
||
-(BOOL)isTouchInRect:(UITouch *)touch; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// CocosNode+Additions.m | ||
// OMGTTT | ||
// | ||
// Created by Jeremy on 12/18/09. | ||
// Copyright 2009 Jeremy Flores. All rights reserved. | ||
// | ||
|
||
#import "CCNode+Additions.h" | ||
|
||
|
||
@implementation CCNode (Additions) | ||
|
||
@dynamic rect, center; | ||
|
||
-(CGRect) rect | ||
{ | ||
return CGRectMake( self.position.x - contentSize_.width*anchorPoint_.x, self.position.y- | ||
contentSize_.height*anchorPoint_.y, | ||
contentSize_.width, contentSize_.height); | ||
} | ||
|
||
-(CGPoint) center { | ||
float x = self.rect.origin.x + self.rect.size.width/2; | ||
float y = self.rect.origin.y + self.rect.size.height/2; | ||
return ccp(x,y); | ||
} | ||
|
||
-(BOOL)isTouchInRect:(UITouch *)touch { | ||
CGPoint touchLocation = [touch locationInView: [touch view]]; | ||
touchLocation = [[CCDirector sharedDirector] convertToGL: touchLocation]; | ||
CGPoint local = [self convertToNodeSpace:touchLocation]; | ||
CGRect r = self.rect; | ||
r.origin = CGPointZero; | ||
if( CGRectContainsPoint( r, local ) ) { | ||
return YES; | ||
} | ||
else { | ||
return NO; | ||
} | ||
} | ||
|
||
@end |
Oops, something went wrong.