1

我目前在屏幕最右侧绘制瓷砖时遇到问题,无法弄清楚是什么原因造成的。正如您在下面链接的图像中看到的那样,地砖应该位于屏幕的右边缘。

正在发生的事情的图片

这是从中绘制的数组的代码副本

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
};
4

1 回答 1

1

问题可能出在您的绘图功能中。每当您制作块、彩虹或梯子时,您都在推动 vViews 向量。确保你在 59 块加上你拥有的其他许多块上调用 draw。能发一下功能吗?

于 2013-07-25T16:06:15.377 回答