Using setChildIndex in flashpunk?


(reopucino) #1

I want to manage my entity, when I click the entity, that will be render first in world, how to use that?? using layer or other methode?


(Alex Larioza) #2

Per entity depths are set by using the layer property.

If you want to set the depths of images within a single entity, you need to use a graphiclist for the entities graphic. Then the order you put the images in the graphiclist determines their depth (or drawing order). For example in the following code image1 (bottom) would be drawn first, then image2, and finally image3 (top):

graphic = new Graphiclist(image1, image2, image3);

(Joseph Sweeney) #3

Wish I would have known about Graphiclist earlier… would have saved a lot of redundant render code!


(Jacob Albano) #4

You can also use the addGraphic method to convert the existing graphic into a graphiclist and add new ones in a single step. :slight_smile: