简体   繁体   中英

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. Or is there anything like z-index property for drawImage() function for canvas?

No, there is no z-index property for the Canvas. The canvas will be drawn in the order you code your drawing primitives.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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