2013-07-25 34 views
1

我目前有問題在屏幕的最右側繪製瓷磚,並且無法找出可能導致此問題的原因。就像你在連接下面的圖片中看到的那樣,地磚應該會到達屏幕的右邊緣。HTML5/JavaScript沒有在屏幕的最右側繪製瓷磚

Image Of what is happening

這裏是數組的代碼副本,從

var mapArray1 = new Array(); 
//    05|     10|    15|     20|   
mapArray1[0] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00); 
mapArray1[1] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);    
mapArray1[2] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00); 
mapArray1[3] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);    
mapArray1[4] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 61, 00, 00, 00, 00, 33, 00, 00, 43);    
// 
mapArray1[5] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 01, 01, 21, 01, 01, 00, 00, 00, 01, 01, 01, 01, 01);    
mapArray1[6] = new Array(00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 21, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);    
mapArray1[7] = new Array(00, 00, 00, 00, 63, 00, 00, 00, 00, 00, 00, 00, 00, 00, 21, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);    
mapArray1[8] = new Array(01, 01, 01, 01, 01, 01, 01, 00, 00, 00, 00, 00, 00, 00, 21, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00);    
mapArray1[9] = new Array(00, 00, 00, 00, 00, 00, 02, 00, 00, 00, 00, 00, 00, 00, 21, 00, 00, 00, 00, 00, 00, 00, 00, 00, 02);    
//10 
mapArray1[10] = new Array(00, 00, 00, 00, 00, 00, 02, 00, 00, 00, 00, 00, 00, 00, 21, 00, 00, 00, 00, 00, 00, 00, 00, 00, 02);    
mapArray1[11] = new Array(00, 00, 00, 00, 00, 00, 02, 00, 00, 00, 00, 00, 01, 01, 01, 01, 01, 00, 01, 21, 01, 01, 01, 01, 02);    
mapArray1[12] = new Array(00, 00, 00, 00, 00, 00, 02, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 21, 00, 00, 00, 00, 00);    
mapArray1[13] = new Array(00, 00, 00, 00, 50, 00, 02, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 21, 00, 41, 00, 00, 00);    
mapArray1[14] = new Array(01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01); 

,在這裏它的圖紙是繪製它

function CreateBlock(tileInt, column, row, bm){ 
    var tileWidth = gameConstants.TILEWIDTH; 

    var blockModel = new AVerletModel(); 
    blockModel._xPos = column * tileWidth + tileWidth/2; 
    blockModel._yPos = row * tileWidth + tileWidth/2; 
    blockModel.SetRectangle(tileWidth, tileWidth, 0xFF7777); 
    vBlocks.push(blockModel); 

    var blockView = new AVerletView(context); 
    blockView.Init(blockModel, bm, tileInt); 
    vViews.push(blockView); 
} 

function CreateLvl(mbm, obm, ebm){ 
    //console.log("CreateLVL"); 
    //now we must create the level 
    for(var i = 0;i< gameConstants.TILESACROSS; i++){ 
     for(var j = 0; j < gameConstants.TILESDOWN; j++){ 
      //defining a target 
      var newPlacement; 
      var iTileInt = mMap.getTile(currentMap, j, i); 
      var iTileType = Math.round(iTileInt/10); 
      var iMod = iTileInt % 10; 

      if(iTileInt != 0){ 
       if(iTileInt < 10){ 
        CreateBlock(iTileInt, i, j, mbm); 
       } 
       else if(iTileType == gameConstants.ENEMY){ 
        console.log("enemy"); 
        //CreateEnemy(iMod, i, j, ebm); 
       } 
       else{ 
        switch(iTileType){ 
         case gameConstants.ORB: 
          newPlacement = new SpriteView(context); 
          newPlacement.Init(iMod, obm, iTileType); 
          vOrbs.push(newPlacement); 
          newPlacement._xPos = i * gameConstants.TILEWIDTH; 
          newPlacement._yPos = j * gameConstants.TILEWIDTH; 
         break; 
         case gameConstants.LADDER: 
          newPlacement = new SpriteView(context); 
          newPlacement.Init(iMod, obm, iTileType); 
          vViews.push(newPlacement); 
          newPlacement._xPos = i * gameConstants.TILEWIDTH; 
          newPlacement._yPos = j * gameConstants.TILEWIDTH; 
         break; 
         case gameConstants.GOAL: 
          goal = new SpriteView(context); 
          goal.Init(iMod, mbm, iTileType); 
          goal._xPos = i * gameConstants.TILEWIDTH; 
          goal._yPos = j * gameConstants.TILEWIDTH; 
         break; 
         case gameConstants.RAINBOW: 
          newPlacement = new SpriteView(context); 
          //console.log(newPlacement.currentTile); 
          newPlacement.Init(5, obm, iTileType); 
          vViews.push(newPlacement); 
          newPlacement._xPos = i * gameConstants.TILEWIDTH; 
          newPlacement._yPos = j * gameConstants.TILEWIDTH; 
         break; 
         case gameConstants.GEMS: 
          newPlacement = new SpriteView(context); 
          newPlacement.Init(iMod, obm, iTileType); 
          vGems.push(newPlacement); 
          newPlacement._xPos = i * gameConstants.TILEWIDTH; 
          newPlacement._yPos = j * gameConstants.TILEWIDTH; 
         break; 
        } 
       }//else 

      }//if 

     }//for 
    }//for 
}; 
+1

圖像似乎並不存在。和這個數組一起工作的代碼是什麼? –

+2

這個數組如何向我們展示HTML的錯誤? –

+1

我已經添加了代碼並修復了圖片問題,現在所有的幫助都會被默認爲謝謝 –

回答

1

的問題可能是代碼在你的繪圖函數中。無論何時製作塊,彩虹或梯子,您都會推動vViews矢量。確保你打電話給59個街區,加上其他許多人。你可以發佈功能嗎?

+0

你是正確的我只是在塊上調用它,非常感謝:) –