即使满足条件,调试器也不会进入该功能

时间:2016-07-26 17:05:20

标签: javascript ionic-framework angular-services javascript-debugger

关于项目:https://github.com/kawai-developers/faster(分支dimitris)在第254行附近的文件www/js/services.js上我有以下代码:

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 one)上,当我点击进入函数gamme.addScore时,我调试它是出于某种原因。

你知道为什么会这样吗?

1 个答案:

答案 0 :(得分:0)

我移动了游戏.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
            }
          });
        };

(有一小撮文件)

相关问题