点击Cocos2d中的处理



我在cocos2d中玩一个游戏,两个人在不同的地方同时点击屏幕,每次点击都算作不同的动作?

这是我当前的代码,不允许同时计算两个抽头:

-(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]];
    }

我在appdelegate中添加了以下代码来处理多点触摸:

[glView setMultipleTouchEnabled:YES];

最新更新