Skip to content

Instantly share code, notes, and snippets.

@TerryCavanagh
Created July 18, 2017 19:59
Show Gist options
  • Select an option

  • Save TerryCavanagh/0fba766108375c95ac7a9a24614ca8dc to your computer and use it in GitHub Desktop.

Select an option

Save TerryCavanagh/0fba766108375c95ac7a9a24614ca8dc to your computer and use it in GitHub Desktop.
Quickly hacked together fade thingy for something
//Quickly hacked together fade thingy for something
import haxegon.*;
import starling.display.*;
import starling.textures.*;
@:access(haxegon.Gfx)
class ColourFade{
public static var level:Float = 0;
public static var color:Int = 0x0;
private static var attached:Bool = false;
private static var img:Image;
private static var rendertexture:RenderTexture;
private static var tempquad:Quad = new Quad(1, 1);
public static function render(newlevel:Float){
level = newlevel;
if (!attached){
rendertexture = new RenderTexture(Gfx.screenwidth, Gfx.screenheight, true);
img = new Image(rendertexture);
img.touchable = false;
Gfx.starstage.addChildAt(img, 1);
attached = true;
}
if (level == 0){
rendertexture.clear(color);
}else{
rendertexture.clear(color, level);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment