아이폰 용 게임 앱을 처음으로 개발 중이고 객관적으로는 여전히 조금 멍청하다.if 및 case 문에 복수 숫자 추가하기
게임은 잘 따라오고있다하지만 난 약간의 문제에 붙어 ...
나는 매 20 명에 대해, 당신이 한 생명을 얻을, 내가 그렇게하는 방법을 알 수 있도록 그것을 만들고 싶어 그러나 이와 같은 잘못 작성된 코드 ...로 :
switch (kills) {
case 20:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 40:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 60:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 80:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 100:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 120:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 140:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 160:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 180:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
break;
case 200:
lives++;
livescount.text = [NSString stringWithFormat:@"%i", lives];
등등 .... 나는 롤 무한대까지이 글을 쓰는 나는이 사실을 알고
을 유지하고 싶지 않아 이것은 부적절한 방법으로 쓰는 것입니다. 전자 코드. 누구든지 매 20 명의 살인 = +1 생명에 대해 적절한 코드를 제공 할 수 있습니까? 아마 코드에 어떻게 작용하는지 이해할 수있을 것입니다.
살인이없는 경우 추가 생명을줍니다. – rmaddy
어쨌든이 if (살인! = 0 && kills % 20 == 0) – Suryakant
이것은 아마도 작동 할 것이지만 나는 지금 내 맥에 없다는 것을 모른다. 그러나 나는 내 0으로 다시 죽이면 점수가 엉망이 될 것입니다. kills2와 같은 보이지 않는 int를 만들 겠지만, 많은 일을 할 것입니다. –