Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #import "CCSprite.h"
  2. @interface Square : CCSprite
  3. @end
  4.  
  5. implementaion file
  6.  
  7. #import "Square.h"
  8. #import "cocos2d.h"
  9. @implementation Square
  10. -(id)init {
  11. // Apple recommend assigning self with supers return value
  12. self = [super init];
  13. if (!self) return (nil);
  14. self.contentSize = [[CCDirector sharedDirector] viewSize];
  15. self.userInteractionEnabled = YES;
  16. return self;
  17. }
  18. -(void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
  19. {
  20. CCLOG(@"touch received");
  21. }
  22. @end
  23.  
  24. - (id)init
  25. {
  26. // Apple recommend assigning self with supers return value
  27. self = [super init];
  28. if (!self) return(nil);
  29.  
  30. Square *_square = [[Square alloc] initWithImageNamed:@"background.png"];
  31. [_square setPosition:CGPointZero];
  32. [self addChild:_square];
  33. // done
  34. return self;
  35. }
  36.  
  37. - (id)initWithTexture:(CCTexture *)texture rect:(CGRect)rect rotated:(BOOL)rotated;
  38.  
  39. - (void)onEnter {
  40. [super onEnter];
  41.  
  42. self.userInteractionEnabled = TRUE;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement