Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 当整数的增量超过一个数的倍数时,如何检查?_Objective C - Fatal编程技术网

Objective c 当整数的增量超过一个数的倍数时,如何检查?

Objective c 当整数的增量超过一个数的倍数时,如何检查?,objective-c,Objective C,我做过一个游戏,玩家会根据他们干掉的敌人类型获得3到5分。我想增加玩家每次得分达到50倍时产生的最大敌人数量 这是我到目前为止得到的(位于调整分数的方法中): if(self.score%50==0) { 如果(self.maxEnemiesA好的话,我宁愿记录你增加数字的分数。在变量中设置当前分数,并检查它是否增加了50以上 if (self.score >= previousScore + 50) { previousScore = self.score;

我做过一个游戏,玩家会根据他们干掉的敌人类型获得3到5分。我想增加玩家每次得分达到50倍时产生的最大敌人数量

这是我到目前为止得到的(位于调整分数的方法中):

if(self.score%50==0)
{

如果(self.maxEnemiesA好的话,我宁愿记录你增加数字的分数。在变量中设置当前分数,并检查它是否增加了50以上

if (self.score >= previousScore + 50) 
{

      previousScore = self.score;
      if (self.maxEnemiesA <= 20)
      {
            self.maxEnemiesA++;
      }

}
if(self.score>=以前的分数+50)
{
上一次得分=自我得分;

如果(self.maxEnemiesA在任何增量之前和之后检查分数

NSInteger oldStep = self.score / 50;
// Code that increments self.score as needed
NSInteger newStep = self.score / 50;
if (newStep > oldStep) {
    // The score has increased into a new multiple of 50
}
示例:如果当前分数为148,
oldStep
将为2。如果随后将分数增加到153,
newStep
将为3。

更简单:

// Let BASE_ENEMIES be the starting number of enemies, when the score is
// less than 50.
self.maxEnemiesA = MIN(20, BASE_ENEMIES + self.score / 50);
// Let BASE_ENEMIES be the starting number of enemies, when the score is
// less than 50.
self.maxEnemiesA = MIN(20, BASE_ENEMIES + self.score / 50);