Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multitouch not working in cocos2D for iPhone

I am quite familiar with cocos2D (been working with it for over 1 year) and I encountered a problem with my multitouch game - the multitouch.

What I have:
[glView setMultipleTouchEnabled:YES] in my delegate. A playscene that does NOT implement touches.
Many objects (of my own, inherits CCLayer) that are added to playscene.
These objects implement touches and are delegates of the targeted protocol.
[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];

The very same architecture is used in the touches test from cocos2D and it's working. The only difference is that they use CCSprite instead of CCLayer as the parent class for the objects.

Does anyone have any ideas?

like image 637
George Avatar asked Jun 21 '11 08:06

George


1 Answers

I do it this way:

in app delegate:

[glView setMultipleTouchEnabled:YES] 

then in you game you see the touches like this:

self.isTouchEnabled = YES;
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)ccTouchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {}

With this I sold my problem I hope it helps

like image 162
Eduardo Iglesias Avatar answered Nov 12 '22 18:11

Eduardo Iglesias