-
Notifications
You must be signed in to change notification settings - Fork 0
Lua API: 2. Window
MCUmbrella edited this page Nov 24, 2023
·
1 revision
Get the coordinates of the top-left corner of the window relative to the top-left corner of the screen.
Return: Integer starting from 0. X is larger the further to the right, Y is larger the further to the bottom.
Set the location mentioned above.
Parameter:
- Number x
- Number y
Example:
-- Put this into tick() to see the window move down to the right
Window.setLocation(
Window.getX() + 1,
Window.getY() + 1
)
Get the size of the window.
Return: Non-negative integer
Set the size of the window.
Parameter:
- Number width
- Number height
Example:
-- Swap the width and height of the window
Window.setSize(Window.getHeight(), Window.getWidth())
Get the title of the window.
Return: String
Set the title of the window.
Parameter:
- String title: The new title to be set.
Example:
-- Put this into tick() to display the current tick in the window title
Window.setTitle("Tick #" .. Engine.currentTick())
Check or control the window's fullscreen state.
Parameter:
- Boolean state (optional): Whether to turn on fullscreen. If the parameter is not present, the fullscreen state remains unchanged.
Return: The current fullscreen state.
Example:
-- Press F11 to toggle fullscreen
if Keyboard.pressed(68) -- F11
then
Window.fullscreen(not Window.fullscreen())
end
Check or control the window's resizable state.
Parameter:
- Boolean state (optional): Whether to make the window resizable. If the parameter is not present, the resizable state remains unchanged.
Return: The current resizable state.
Example:
Window.resizable(true) -- allows window resizing