Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "ControlLayer2.h"
- extern int CONTROL_LAYER_TAG;
- @implementation ControlLayer2
- +(id)ControlLayer2WithParentNode:(CCNode *)parentNode{
- ControlLayer2 *control = [[self alloc] init];
- [parentNode addChild:control z:0 tag:CONTROL_LAYER_TAG];
- return control; //Guru
- }
- -(id)init{
- if (self=[super init]){
- }
- return self;
- }
- - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- {
- UITouch *myTouch = [touches anyObject];
- CGPoint location = [myTouch locationInView:[myTouch view]];
- location = [[CCDirector sharedDirector] convertToGL:location];
- //handle touch
- }
- @end
- @implementation GameScene
- +(id)scene{
- CCScene *scene = [CCScene node];
- CCLayer *layer = [GameScene node];
- [scene addChild:layer z:0 tag:0];
- return scene;
- }
- -(id)init{
- if(self = [super init]){
- //[[[CCDirector sharedDirector]touchDispatcher] addTargetedDelegate:[self getChildByTag:0] priority:0 swallowsTouches:YES];
- //add the player layer to the game scene (this contains the player sprite)
- mControlLayer2 = [ControlLayer2 ControlLayer2WithParentNode:self];
- mPlayerLayer = [PlayerLayer PlayerLayerWithParentNode:self];
- self.touchEnabled = YES; //guru, in old cocos2d its self.isTouchEnabled = YES;
- }
- return self;
- }
- - (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- {
- [mControlLayer2 ccTouchesBegan:touches withEvent:event];
- [mPlayerLayer ccTouchesBegan:touches withEvent:event];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement