Objective-C使用IF语句停止计数器

时间:2012-08-29 04:30:04

标签: objective-c cocoa-touch cocos2d-iphone

我有一个使用if语句的分数计数器

 if (CGRectIntersectsRect(aliens.boundingBox, heroe.boundingBox)) {
        heroe.visible = NO;
        //HOW DO I STOP THE SCORE++ HERE?
  } 
  else {
        score++;
        [scoreLabel setString: [NSString stringWithFormat:@"%i", score]];

  }

我无法找到一种方法来阻止分数++

任何提示?

1 个答案:

答案 0 :(得分:0)

尝试这个

if (CGRectIntersectsRect(aliens.boundingBox, heroe.boundingBox)) {

heroe.visible = NO;

}
else{
if(heroe.visible == yes)
score++;

[scoreLabel setString: [NSString stringWithFormat:@"%i", score]];

}