-
Notifications
You must be signed in to change notification settings - Fork 0
Layer.move
Terry Cavanagh edited this page Feb 28, 2018
·
1 revision
Layer.move(layername:String, x:Float, y:Float);
Move a layer to a new position.
-
layername
: The name of the layer to check. -
x/y
: Position to move to.
import haxegon.*;
class Main{
function init(){
Layer.create("foreground");
Layer.attach("foreground");
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(){
//Press ARROW KEYS to change the position of the "foreground" layer
var x:Float = Layer.getx("foreground");
var y:Float = Layer.gety("foreground");
if (Input.pressed(Key.LEFT)) x -= 5;
if (Input.pressed(Key.RIGHT)) x += 5;
if (Input.pressed(Key.UP)) y -= 5;
if (Input.pressed(Key.DOWN)) y += 5;
Layer.move("foreground", x, y);
}
}