Screen
Clay backend screen and window management implementation.
This class handles screen-related operations including:
- Window dimensions and display properties
- Window title and fullscreen state management
- Screenshot capture functionality (texture, PNG, raw pixels)
- Mouse and touch input event handling
- Audio context resumption on web platforms
Platform-specific features:
- Web: HTML5 Canvas and Electron integration for fullscreen
- Desktop (SDL): Direct OpenGL framebuffer reading for screenshots
- Mobile: Touch input event handling and audio context management
Instance Members
Gets the current screen width in pixels.
Returns | Description |
---|---|
Int | Screen width in pixels |
Gets the current screen height in pixels.
Returns | Description |
---|---|
Int | Screen height in pixels |
Gets the current screen pixel density/scale factor.
Returns | Description |
---|---|
Float | Pixel density (1.0 = standard, 2.0 = retina/high-DPI, etc.) |
Sets the window background color.
Note: This method is currently unused as background clearing is handled directly in the draw loop.
Name | Type | Description |
---|---|---|
background |
Int | Background color as integer |
Sets the window title text.
Name | Type | Description |
---|---|---|
title |
String | New window title |
Sets the window fullscreen state.
On web platforms, this checks for Electron runner integration and uses native fullscreen if available, otherwise falls back to HTML5 fullscreen API.
Name | Type | Description |
---|---|---|
fullscreen |
Bool | True to enable fullscreen, false to disable |
Name | Type |
---|---|
done |
Function |
Name | Type | Default |
---|---|---|
path |
String | (optional) |
done |
Function |
Name | Type |
---|---|
done |
Function |
Creates a new Screen backend instance.
Private Members
Index counter for generating unique screenshot identifiers.
Fired when the screen/window is resized.
Fired when a mouse button is pressed down.
Name | Type | Description |
---|---|---|
buttonId |
Int | Mouse button ID (0=left, 1=middle, 2=right) |
x |
Float | Mouse X coordinate |
y |
Float | Mouse Y coordinate |
Fired when a mouse button is released.
Name | Type | Description |
---|---|---|
buttonId |
Int | Mouse button ID (0=left, 1=middle, 2=right) |
x |
Float | Mouse X coordinate |
y |
Float | Mouse Y coordinate |
Fired when the mouse wheel is scrolled.
Name | Type | Description |
---|---|---|
x |
Float | Horizontal scroll amount |
y |
Float | Vertical scroll amount |
Fired when the mouse cursor moves.
Name | Type | Description |
---|---|---|
x |
Float | Mouse X coordinate |
y |
Float | Mouse Y coordinate |
Fired when a touch begins on the screen.
Name | Type | Description |
---|---|---|
touchIndex |
Int | Touch point index for multi-touch |
x |
Float | Touch X coordinate |
y |
Float | Touch Y coordinate |
Fired when a touch ends.
Name | Type | Description |
---|---|---|
touchIndex |
Int | Touch point index for multi-touch |
x |
Float | Touch X coordinate |
y |
Float | Touch Y coordinate |
Fired when a touch point moves.
Name | Type | Description |
---|---|---|
touchIndex |
Int | Touch point index for multi-touch |
x |
Float | Touch X coordinate |
y |
Float | Touch Y coordinate |
Metadata
Name | Parameters |
---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |