2

我在 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]];
    }
4

1 回答 1

0

我将以下代码添加到我的 appdelegate 以处理多点触控:

[glView setMultipleTouchEnabled:YES];
于 2012-03-03T17:37:24.240 回答