In my app delegate, I made sure I have the line:
[glView setMultipleTouchEnabled: YES];
And I have a simple layer meant only to figure out how multi touch works. The .mm file looks like:
#import "TestLayer.h"
@implementation TestLayer
-(id) init
{
if( (self=[super init])) {
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
return self;
}
-(void) draw{
[super draw];
glColor4f(1.0, 0.0, 0.0, 0.35);
glLineWidth(6.0f);
ccDrawCircle(ccp(500,500), 250,CC_DEGREES_TO_RADIANS(360), 60,YES);
}
-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"got some touches");
}
-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"some touches moved.");
}
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
NSLog(@"a touch began");
return FALSE;
}
@end
When I touch the screen, I always see “a touch began”, but no matter how I touch it (simulator or actual device), I never see “some touches moved” or “got some touches”.
Is there something further I need to do to make multi touch work?
Specifically, I’m just trying to do basic pinch-to-zoom functionality… I heard there is some sort of gesture recognizer for iPhone…does it work for Coco2ds? Would it work even if I can’t get simple multi touch events to fire?
UIGestureRecognizersabsolutely work for Cocos2D, I personally used them, you just need to add them to the correct view by using:Regarding your touches, I guess you enabled them for the scene you are working in?
In any case you shouldn’t use the
addTargetDelegatemethod, take a look here