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.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.
Example:
importhaxegon.*;
classMain{
functioninit(){
Layer.create("foreground");
Layer.attach("foreground");
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 ARROW KEYS to change the position of the "foreground" layervarx:Float=Layer.getx("foreground");
vary: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);
}
}