Javascript 在html5画布中的另一个图像下绘制图像
正如你所见,我试图在我的画布内绘制一个水平场。坦克和敌人的图像被绘制在水平场下方,这可能是一个问题,因为坦克和敌人应该在一个JSFIDLE的水平场图像上方移动: (x=0;xJavascript 在html5画布中的另一个图像下绘制图像,javascript,jquery,canvas,Javascript,Jquery,Canvas,正如你所见,我试图在我的画布内绘制一个水平场。坦克和敌人的图像被绘制在水平场下方,这可能是一个问题,因为坦克和敌人应该在一个JSFIDLE的水平场图像上方移动: (x=0;x
{
对于(y=0;y
内容按照您呈现给上下文的顺序呈现。要在游戏区域的顶部绘制坦克和敌人,请确保首先绘制游戏区域(瓷砖),最后绘制坦克和敌人
有点像:
// Draw all the tiles
ctx.drawImage(img....);
// Draw the enemies
ctx.drawImage(enemy...);
// Draw the tank
ctx.drawImage(tank...);
// Draw all the tiles
ctx.drawImage(img....);
// Draw the enemies
ctx.drawImage(enemy...);
// Draw the tank
ctx.drawImage(tank...);