E
E
ekdown2014-08-17 19:49:18
JavaScript
ekdown, 2014-08-17 19:49:18

How to determine the stacking order of images on a canvas?

Good evening!
I'm creating a game on HTML5 Canvas , something like this:
megapolis1.jpg
All buildings/roads will be drawn on canvas
SVG had to be abandoned so as not to hang mobile (and not only) browsers by the legs .
Images in the process of rendering overlap each other, but this needs to be controlled somehow - the smaller the ordinate ( y ) , the "further" the layer with the image of the building will be.
So how do you control the stacking order of rendered images?
UPD: How much will it slow down the browser to use a separate canvas for each building?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
barkalov, 2014-08-17
@barkalov

So how do you control the stacking order of rendered images?
Draw in the correct order. From far to near.
After they have already been drawn - no way.

P
Pavel Kityan, 2014-08-17
@bookworm

Use libraries like Paper.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question