Question

Im working on a game in cocos2d where two people tap on the screen at the same time in different places and each tap counts as a different action?

This is my current code, which doesn't allow the two taps to be counted at the same time:

-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *myTouch = [touches anyObject];
    CGPoint point = [myTouch locationInView:[myTouch view]];
    point = [[CCDirector sharedDirector] convertToGL:point];

    if (point.y > 512) {
        score += 1;
        [scoreLabel setString:[NSString stringWithFormat:@"%i", score]];
    }
    if (point.y < 512) {
        score2 += 1;
        [scoreLabel2 setString:[NSString stringWithFormat:@"%i", score2]];
    }
Était-ce utile?

La solution

I added the following code to my appdelegate to handle multi-touch:

[glView setMultipleTouchEnabled:YES];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top