Root - LiruJ/GuiCookie GitHub Wiki
The Root class is a base class for a layout, any UI layout in GuiCookie requires a form of Root.
It can be thought of as a large controller class, it handles the larger elements of the layout and ensures the overarching UI logic functions. For example; a 2D platformer may have elements for the health counter, collectibles counters, timer, and pause menu, these would all be referenced in the root class so that elements can be hidden and shown when the player pauses the game.
Root classes are not specific to a layout sheet, so they may be reused across many layouts, although such a situation is quite rare.
Holds the root-level elements and handles element creation.
Handles all mouse and keyboard input.
Keeps track of any dragged element and handles interaction between draggables and drop targets.
Handles the loading and storage of styles and resources.
Handles the loading and storage of templates.
Stores the attributes of the main root node.
Bounds
The bounds of the game window, including padding.
bool
Gets a value that is true when the mouse is over an element; otherwise false.
This is neccessary when discerning between UI interactions and game interactions. For example; if your game takes input by the player clicking on things, you would want to ensure this is false as it would mean they are instead clicking on the UI.
bool
Is true if the layout file has been loaded and the starting elements set up; otherwise false. This is set to true immediately before PostInitialise().
protected, virtual, void
This is called immediately after every manager property has been set, but nothing else has been loaded.
protected, virtual, void
This is called immediately before the elements are loaded from the XML layout sheet. The sheet itself will still be loaded, so the attributes, templates, styles, and bounds will be set up.
protected, virtual, void
This is called immediately after the elements are loaded from the XML layout sheet.
protected, virtual, void
This is the very last initialisation function to be called. All element and component setup functions will have executed by this point.
public, Element
Finds and returns the element with the given tag. Each tag must be unique.
This returns null if no element with the given tag exists.
public, T
Finds and returns the element with the given tag, cast as the given type T.
public, void
Removes the given element from the layout.
public, void
Updates the input, then each element.
protected, virtual, void
Is called immediately before the main update function.
protected, virtual, void
Is called immediately after the main update function.
public, void
Calls the draw function on all root-level elements.
protected, virtual, void
Is called immediately before the main draw function.
protected, virtual, void
Is called immediately after the main draw function.