Skip to content

Layer.alpha

Terry Cavanagh edited this page Feb 28, 2018 · 1 revision
Layer.alpha(layername:String, [alpha:Float = 1.0]);

Set the alpha of a layer.

  • layername: The name of the layer to check.
  • alpha: Alpha value of the layer. Leave blank to restore to 1.0.

Example:

import haxegon.*;

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

    //Set the alpha of the "foreground" layer to 0.5.
    Layer.alpha("foreground", 0.5);
    	
    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));
    }
    Gfx.drawtoscreen();
  }

  function update(){
  }
}
Clone this wiki locally