AbstractMoveableScreen
The AbstractMoveableScreen
class is an abstract class that extends the Screen
class. It provides a framework for creating screens that can contain movable widgets. This class is required for handling widget input and editor.
Class Variables
WidgetRenderer widgetRenderer
: TheWidgetRenderer
object responsible for rendering the widgets on this screen.int snapSize
: Number of grids in which the screen should be divided to which the widgets will snap when moved. Default value is 100. Higher value == Smaller grid boxes.boolean shouldPause
: A flag indicating whether the game should pause when this screen is opened.
Constructor
The constructor takes a Text
object representing the title of the screen and a WidgetRenderer
object.
Methods
void onDisplayed()
: This method is called when the screen is displayed. It sets theisInEditor
flag of thewidgetRenderer
totrue
.void render(DrawContext drawContext, int mouseX, int mouseY, float delta)
: This method is responsible for rendering the screen and its widgets. It first checks if the client’s world isnull
, and if so, it renders the background texture. Then it calls therenderWidgets
method of thewidgetRenderer
to render each widget.void close()
: This method is called when the screen is closed. It sets theisInEditor
flag of thewidgetRenderer
tofalse
and calls theonCloseScreen
method of thewidgetRenderer
.void setShouldPause(boolean shouldPause)
: This method sets theshouldPause
flag to the given value.boolean shouldPause()
: This method returns the value of theshouldPause
flag.void setSnapSize(int size)
: This method sets thesnapSize
to the given value.
Last updated
Was this helpful?