0

I'm trying to get a dynamic rendering order going in ocanvas but can't find any information in the docs about how to go about doing it. I want something along the lines of "the object's y position affects the order in which it is rendered", it's for an isometric game engine. Any help would be greatly appreciated.

thanks

Jeff
  • 19
  • 1
  • 1
  • 6

1 Answers1

0

There's nothing automatic for this, but you can probably implement it quite easily with the zIndex property: http://ocanvas.org/docs/Display-Objects/Base#property-zIndex

  • Hi Johannes, I tried that but it didn't work. I tried making the zindex of the object equal to its y position. perhaps I'm not using it correctly? – Jeff May 21 '15 at 07:51
  • it seems that no matter what they are rendered in the order they are added to the canvas – Jeff May 21 '15 at 07:57
  • The `zIndex` property is a real index for the object in the list of children for its parent, which means you can't use the `y` value directly, but you can convert it to get the index you want. I made an example here (drag around the rectangles to try it): http://jsfiddle.net/ky3z7mjg/ – Johannes Koggdal May 21 '15 at 23:00