Is it possible to clear/erase a canvas?


(christopf) #1

hey, is it possible to erase the canvas somehow? i have different states which show different symbols upon the head of my protagonist. but if i just change em, they get added and not cleared.

i tried to make a workaround and always create a new canvas (on the same var) when a new symbol was cast. but it seems as the update() function got called after the render().


(JP Mortiboys) #2

This will clear the canvas:

var r:Rectangle = new Rectangle(0, 0, canvas.width, canvas.height);
canvas.fill(r, 0, 0);

You might also want to think about using a different mechanism for displaying the symbols; if you’ve got specified slots and icons, a Tilemap might be appropriate. If they’re animated, perhaps a set of Spritemap graphics would work well.


(christopf) #3

Hey that idea with spritemap is quite clever. This should work also.

But in first place this is for the #ld jam and i never tried to paint objects with the render function. so i thought its good opportunity to try ((:

ty i will try it with the rect first and if that aint working i switch to the spritemap i guess