Skip to content

"screen"

Terry Cavanagh edited this page Feb 28, 2018 · 2 revisions
Layer.detach("screen");

In Layers, "screen" is a special pre-defined layer that you can manipulate. It can be moved, rotated, scaled and detached just like any other layer.

Here's a simple screenshake example:

Example:

import haxegon.*;

class Main{
  function update(){
    //Draw some boxes on the screen
    for (j in 0 ... 10){
      for (i in 0 ... 10){
        var boxwidth:Float = Gfx.screenwidth / 10;
        var boxheight:Float = Gfx.screenheight / 10;
        Gfx.fillbox(i * boxwidth, j * boxheight, boxwidth, boxheight, Col.hsl((i + j) * 45, 0.5, 0.5));
      }
    }
    	
    //Shake the screen around randomly
    Layer.move("screen", Random.int( -10, 10), Random.int( -10, 10));
  }
}

Clone this wiki locally