Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "CCSprite.h"
- @interface Square : CCSprite
- @end
- implementaion file
- #import "Square.h"
- #import "cocos2d.h"
- @implementation Square
- -(id)init {
- // Apple recommend assigning self with supers return value
- self = [super init];
- if (!self) return (nil);
- self.contentSize = [[CCDirector sharedDirector] viewSize];
- self.userInteractionEnabled = YES;
- return self;
- }
- -(void)touchBegan:(UITouch *)touch withEvent:(UIEvent *)event
- {
- CCLOG(@"touch received");
- }
- @end
- - (id)init
- {
- // Apple recommend assigning self with supers return value
- self = [super init];
- if (!self) return(nil);
- Square *_square = [[Square alloc] initWithImageNamed:@"background.png"];
- [_square setPosition:CGPointZero];
- [self addChild:_square];
- // done
- return self;
- }
- - (id)initWithTexture:(CCTexture *)texture rect:(CGRect)rect rotated:(BOOL)rotated;
- - (void)onEnter {
- [super onEnter];
- self.userInteractionEnabled = TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement