Window
Window size, fullscreen, title, and design size (logical resolution) with scale mode. All methods are static. Design size is the logical resolution (e.g. 400×300); scale mode controls how it is mapped to the window.
Size & title
Section titled “Size & title”Window.getWidth() / Window.getHeight()
Section titled “Window.getWidth() / Window.getHeight()”Returns: Num — Current window width or height in pixels.
var w = Window.getWidth()var h = Window.getHeight()Gui.label("Window: %(w) x %(h)")Window.getTitle()
Section titled “Window.getTitle()”Returns: String — Current window title.
Window.getFullscreen() / Window.setFullscreen(fullscreen)
Section titled “Window.getFullscreen() / Window.setFullscreen(fullscreen)”Returns: (getter) Bool — Whether the window is fullscreen.
Parameters:
fullscreen(Bool) —truefor fullscreen,falsefor windowed.
if (Gui.buttonLabel("Toggle fullscreen")) { Window.setFullscreen(!Window.getFullscreen())}Window.setSize(width, height)
Section titled “Window.setSize(width, height)”Parameters:
width(Num) — Width in pixels.height(Num) — Height in pixels.
Set the window size in pixels. Ignored or clamped in fullscreen depending on the host.
Design size & scale mode
Section titled “Design size & scale mode”Design size = logical resolution (e.g. 400×300). Content is laid out in this space; the scale mode decides how it is scaled to the actual window.
- stretch — Fill the whole window (may distort aspect).
- letterbox — Fit inside the window, keep aspect ratio (may show bars).
- integer — Like letterbox but use integer scale for sharp pixels.
Set design size to 0×0 or use stretch to effectively use the full framebuffer. Changes apply on the next frame.
Window.getDesignWidth() / Window.getDesignHeight()
Section titled “Window.getDesignWidth() / Window.getDesignHeight()”Returns: Num — Current design (logical) width or height. Zero means “use window size” (stretch).
Window.getScaleMode() / Window.setScaleMode(mode)
Section titled “Window.getScaleMode() / Window.setScaleMode(mode)”Returns: (getter) String — Current scale mode: "stretch", "letterbox", or "integer".
Parameters:
mode(String) —"stretch","letterbox", or"integer". Uses the current design size.
Window.setScaleMode("letterbox")Window.setDesignSize(width, height, scaleMode)
Section titled “Window.setDesignSize(width, height, scaleMode)”Parameters:
width(Num) — Design width (0 = use window width).height(Num) — Design height (0 = use window height).scaleMode(String) —"stretch","letterbox", or"integer".
Set design size and scale mode in one call. Takes effect next frame.
Window.setDesignSize(1280, 720, "letterbox")