Objective-C得分计数

时间:2015-09-23 16:39:07

标签: ios objective-c

我手里拿着一只脆弱的鸟儿克隆。我试图理解为什么分数不正确。它有时不会注册管道。我是一个新手:)

- (void) updateScore:(NSTimeInterval) currentTime
{
    for(int i=0;i<nbObstacles;i++){

        SKSpriteNode * topPipe = (SKSpriteNode *) topPipes[i];

        // Score, adapt font size
        if(X(topPipe) + WIDTH(topPipe)/2 > bird.position.x &&
           X(topPipe) + WIDTH(topPipe)/2 < bird.position.x + FLOOR_SCROLLING_SPEED){
            self.score +=1;
            scoreLabel.text = [NSString stringWithFormat:@"%lu",self.score];
            if(self.score>=10){
                scoreLabel.fontSize = 340;
                scoreLabel.position = CGPointMake(CGRectGetMidX(self.frame), 120);
            }
        }
    }
}

1 个答案:

答案 0 :(得分:0)

// Score, adapt font size
    if(X(topPipe)+1 > bird.position.x &&
       X(topPipe) < bird.position.x + FLOOR_SCROLLING_SPEED){
        self.score +=1;

这解决了一切