Add graphic in Entity BEHIND the main graphic


(Zeeshan Ahmad) #1

So I’m new to Flashpunk, or any game engine for that matter.

In my entity I wanted to animate (which I can do) a secondary graphic appear from behind (which I can’t achieve) the main graphic of the entity. Does any body know how I achieve this?


(Ultima2876) #2

Use a graphiclist.

backGraphic = new Image(GFX_BACKTHING);
mainGraphic = new Spritemap(GFX_MY_SPRITEY_POO, 100, 100);
graphic = new Graphiclist(backGraphic, mainGraphic);

Graphiclists are rendered in the order the arguments are passed. In this case, backGraphic is drawn first, with mainGraphic drawn on top of it. If you want to tweak the relative positions of the graphics, do so like this:

backGraphic.x = -50;
mainGraphic.y = 270;

(Zeeshan Ahmad) #3

Thanks that has most definitely worked for me!