HTML5/Javascript不在屏幕最右侧绘制平铺 我现在有问题在屏幕最右边画瓷砖,不能弄清楚是什么引起了这个问题。正如您在下面链接的图像中所看到的,地板砖应该位于屏幕的右边缘
下面是从中绘制图形的阵列的代码副本HTML5/Javascript不在屏幕最右侧绘制平铺 我现在有问题在屏幕最右边画瓷砖,不能弄清楚是什么引起了这个问题。正如您在下面链接的图像中所看到的,地板砖应该位于屏幕的右边缘,javascript,html,Javascript,Html,下面是从中绘制图形的阵列的代码副本 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, 0
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
};
函数CreateBlock(tileInt、column、row、bm){
var tileWidth=gameConstants.tileWidth;
var blockModel=新的AVerletModel();
块模型。_xPos=列*tileWidth+tileWidth/2;
块模型。_yPos=行*波浪宽度+波浪宽度/2;
块模型.SetRectangle(tileWidth,tileWidth,0xFF7777);
vBlocks.push(blockModel);
var blockView=新的AVerletView(上下文);
blockView.Init(blockModel、bm、tileInt);
vViews.push(块视图);
}
函数CreateLvl(mbm、obm、ebm){
//console.log(“CreateLVL”);
//现在我们必须创建级别
对于(var i=0;i
问题可能出在绘图函数中。无论何时创建块、彩虹或梯子,都将推送到VView向量。确保您在59个街区上调用draw,再加上您拥有的其他街区。你能发布函数吗?问题可能出在你的draw函数中。无论何时创建块、彩虹或梯子,都将推送到VView向量。确保您在59个街区上调用draw,再加上您拥有的其他街区。你能发布函数吗?图像似乎不在那里。使用这个数组的代码是什么?这个数组如何向我们展示你的HTML出现了什么问题?我已经添加了代码并修复了图片问题。如果循环在遍历整个数组之前终止,任何帮助都会得到响应?循环逻辑或平铺绘制过程中有问题吗?CreateBlock函数被调用59次,但它只绘制49个平铺图像似乎不存在。使用这个数组的代码是什么?这个数组如何向我们展示你的HTML出现了什么问题?我已经添加了代码并修复了图片问题。如果循环在遍历整个数组之前终止,任何帮助都会得到响应?循环逻辑或平铺绘制过程中有问题吗?CreateBlock函数被调用59次,但只绘制了49个平铺。你是对的,我只是在块上调用它。非常感谢:)你是对的,我只是在块上调用它。非常感谢:)