0

在项目中的功能:对文件www/js/services.jshttps://github.com/kawai-developers/faster(分支季米特里斯)围绕线254我有folloging代码:调试DES没有踏进即使条件满足

game.remove_deleted_items=function() 
{ 
    var deleted=move_items_on_the_top(); 

    game.grid.loopItems(function(item,i,j,values,game) 
    { 
    console.log(item.status); 
    if(item.status==='destroyed') 
    { 
     console.log("Δαμέ"); 
     values[i][j]= game.randomItem(values[i][j]);//Replace the item with the new one 
     game.addScore(1); 
    } 
    }); 
}; 

但由于某些原因,即使下面的行执行:

values[i][j]= game.randomItem(values[i][j]); 

下面的行不是:

game.addScore(1); 

他们都处于相同的状态,游戏物品可以访问。此外该方法存在并具有以下实现:

game.addScore=function(points) 
{ 
    console.log(points); 
    game.points.value+=points; 
    console.log("Helllo adding points"); 
} 

但在我的调试器(Firefox的一个)我调试它由于某种原因,当我点击的步骤,以它没有功能gamme.addScore

你有什么想法为什么会发生这种情况?

+1

因此,不管是运行的代码通常也不进行调试将打'的console.log(点);'?它只是永远不会被打到?如果你把一个日志放在'game.addScore(1);'下面,那会怎样? – dlsso

+0

既不是你建议的woorked方式,我只是把game.addScore(1);进入另一个地方,像一个魅力一样的安逸。 –

+0

我没有提出任何有关如何使其工作的建议,我只是想弄清楚究竟发生了什么。很高兴你的工作虽然。 – dlsso

回答

0

我移动了game.addScore(1);回调外,因此game.remove_deleted_items是:

game.remove_deleted_items=function() 
     { 
      var deleted=move_items_on_the_top(); 
      if(deleted) 
      { 
      deleted.forEach(function() 
      { 
       game.addScore(1); 
      }); 
      } 

      // I Loop through the grid because I want the i,j position for each item too. 
      game.grid.loopItems(function(item,i,j,values,game) 
      { 
      console.log(item.status); 
      if(item.status==='destroyed') 
      { 
       values[i][j]= game.randomItem(values[i][j]);//Replace the item with the new one 
      } 
      }); 
     }; 

(随着文档的捏)

相关问题