Canvas.layer & Canvas.spritemap?


(christopf) #1

Is there a possibility to add a spritemap direct to a canvas (or do i have to workaround) and is it possible to change the canvas layer (it aint in the absolute front in my game but i guess how i could workaround just wondering if theres a direct way)?


(Ultima2876) #2

Is your Canvas in an Entity class? Just change the layer of the Entity that contains the Canvas.

graphic = myCanvas;
layer = -100; //whatever layer

To add a spritemap you could use a Graphiclist;

graphic = myCanvas;
addGraphic(mySpritemap);

If your Canvas isn’t in an Entity class, you could do it this way I guess:

var myEntity: Entity = new Entity(xPos, yPos, myCanvas);
myEntity.addGraphic(mySpritemap);
myEntity.layer = -100; //whatever layer
add(myEntity); //add the Entity to the world

(christopf) #3

thanks! worked very well