Copy from another canvas to the flambe canvas on top of everything?

20 views
Skip to first unread message

Jon Grant

unread,
Feb 25, 2015, 11:33:30 PM2/25/15
to fla...@googlegroups.com
I'm drawing to a canvas in memory and then on update drawing to the flambe canvas.  Unfortunately, it is behind everything.  How can I make my draw function happen after all the other sprites draw?

Jon Grant

unread,
Feb 25, 2015, 11:54:28 PM2/25/15
to fla...@googlegroups.com
Nothing like askig a question to help figure out the answer....

I created a sprite subclass that created an empty canvas and got reference to the flambe canvas. The sprite's canvas context is public.  I draw on the context, then copy the sprites canvas to the main canvas on the draw operation.


class CanvasSprite extends Sprite
{
private var _stageCanvas:Dynamic;
private var _drawCanvas:Dynamic;
private var _ctx:Dynamic;
@:keep public function new() 
{
super();
#if html
_stageCanvas =  Browser.document.getElementById("flambeCanvasName");
_drawCanvas =  HtmlUtil.createEmptyCanvas(Std.int(Main.DEFAULT_WIDTH), Std.int(Main.DEFAULT_HEIGHT));
_ctx = _drawCanvas.getContext('2d');
#end
}

override public function draw(g:Graphics) 
{
super.draw(g);
_stageCanvas.getContext('2d').drawImage(_drawCanvas, 0,0);
}
private function get_ctx():Dynamic 
{
return _ctx;
}
public var ctx(get_ctx, null):Dynamic;
Reply all
Reply to author
Forward
0 new messages