简体   繁体   English

在HTML5中动态更改图像的顺序-画布

[英]Changing the order of images dynamically in HTML5 - Canvas

I'm trying to make a little isometric game.There are objects and players. 我正在尝试制作一些等距游戏。有对象和玩家。

In init function; 初始化函数;

drawObject();
drawPlayer();

So in screen player always shown in top of objects because player drawn after objects but it should be like that; 因此,在屏幕上,播放器始终显示在对象的顶部,因为播放器是在对象之后绘制的,但是应该像这样; if y-coordinate of the object is more than the player's y-coordinate then object must be drawn later and shown on top. 如果对象的y坐标大于玩家的y坐标,则必须稍后绘制对象并显示在顶部。 Or is there anything like z-index property for drawImage() function for canvas? 还是画布的drawImage()函数有类似z-index属性的东西?

No, there is no z-index property for the Canvas. 不,画布没有z-index属性。 The canvas will be drawn in the order you code your drawing primitives. 将按照您编写绘图图元的顺序绘制画布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM