You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Terry Cavanagh edited this page Feb 28, 2018
·
1 revision
Layer.getalpha(layername:String):Float;
Get the alpha of a layer. Default is 1.0.
layername: The name of the layer to check.
Example:
importhaxegon.*;
classMain{
functioninit(){
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 (iin0...200){
//Draw 200 random circles on the "foreground" layerGfx.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();
}
functionupdate(){
//Press LEFT and RIGHT to change the alpha of the "foreground" layervarcurrentalpha:Float=Layer.getalpha("foreground");
if (Input.pressed(Key.LEFT)){
Layer.alpha("foreground", Geom.clamp(currentalpha-0.05, 0, 1));
}elseif (Input.pressed(Key.RIGHT)){
Layer.alpha("foreground", Geom.clamp(currentalpha+0.05, 0, 1));
}
}
}