GUI

Sizes

Each GUI element has a width and height, commonly written as W and H.

Position

** *Some things here are true only if you have a positive width and height.

The GUI System's position is pretty simple to understand, we have: x or left, y or top, right, bottom and center

  • X or Left - Moves the object left the more you add to it.
  • Y or Top - Moves the object bottom the more you add to it.
  • Right - Combination of the width and X position gives us the "right" position of the object, goes left the more you add.
  • Bottom - Same as right but now with Y position and height, goes bottom the more you add.
  • Center - Combination of the X or Y position and half of the width or height, there's center x and center y both act the same as normal x and y.

World positions

Normally the object's position is its position inside its parent, the world position is where the object really is in the screen(most of the times)

Set functions

set_name(string name) : Sets a name for the object, panels can find the object using the child function.

For world positon just add _world after set(like set_world_x)

  • set_x(number x) / set_left(number x) : Sets the X position.
  • set_y(number y) / set_top(number y) : Sets the Y position.
  • set_position(number x, number y) / set_lefttop(number x, number y) : Same as set_x and set_y but combined.
  • set_w(number width), set_width(number width) : Sets the width of the object.
  • set_h(number height), set_height(number height) : Sets the height.
  • set_size(number width, number height) : Same as set_w and set_h but combined.
  • set_shape(number x, number y, number width, number height) : Sets the position and size of the object.
  • set_right(number right) : Sets the right position(sets the X position to your number minus the object's width)
  • set_bottom(number bottom) : Sets the bottom position(sets the Y position to your number minus the object's height)
  • set_center_x(number center_x) : Sets the center x position(sets the X position to your number minus the half of the object's width)
  • set_center_y(number center_y) : Sets the center y position(sets the Y position to your number minus the half of the object's height)
  • set_center(number center_x, number center_y) : Same as the two top but combined.
  • set_leftbottom(number x, number bottom) : set_x and set_bottom but combined.
  • set_rightbottom(number right, number bottom) : set_right and set_bottom but combined.
  • set_righttop(number right, number y) : set_right and set_y but combined.

Get functions

  • name() : Returns the name of the object

For world positon just add 'world_' to the function name(like world_x)

  • x(), left() : Returns the X position.
  • y(), top() : Returns the Y position.
  • position(), lefttop() : Returns X, Y positions.
  • w(), width() : Returns the width.
  • h(), height() : Returns the height.
  • size() : Returns width, height.
  • shape() : Returns X,Y,width,height.
  • right() : Retruns X + Width.
  • bottom() : Returns Y + Height.
  • center_x() : Returns X + (Width / 2)
  • center_y() : Returns Y + (Height / 2)
  • center() : returns center X, center Y positions.
  • leftbottom() : returns X, bottom positions.
  • rightbottom() : returns right, bottom positions.
  • righttop() : returns right, y positions.