Skip to content

Layer.drawto

Terry Cavanagh edited this page Feb 28, 2018 · 1 revision
Layer.drawto(layername:String);

Draw to the named layer. Call Gfx.drawtoscreen() when you're finished to draw to the screen again.

  • layername: The name of the layer to draw to.

Example:

import haxegon.*;

class Main{
  function init(){
    Layer.create("foreground");
    Layer.attach("foreground");

    //Draw to the "foreground" layer.
    Layer.drawto("foreground");
    for (i in 0 ... 200){
      //Draw 200 random circles on the "foreground" layer
      Gfx.fillcircle(Random.int(0, Gfx.screenwidth), Random.int(0, Gfx.screenheight), Random.int(50, 80), Col.hsl(Random.int(0, 360), 0.5, 0.5));
    }
    //Once we're done, we call this to draw to the screen again.
    Gfx.drawtoscreen();
  }

  function update(){
  }
}
Clone this wiki locally