Screen
Provides functionalities to control and query properties of the game screen, such as dimensions, pixel density, fullscreen mode, safe areas, sleep timeout, and brightness adjustment.
Properties
Retrieves the current width of the game screen in pixels. Can be used to adjust the game's layout based on the screen's width.
local width = Screen.width
print("Screen width: " .. width)
Retrieves the current height of the game screen in pixels. Can be used to adjust the game's layout based on the screen's height.
local height = Screen.height
print("Screen height: " .. height)
Provides the current screen resolution in dots per inch. Can be used to adjust the game's layout based on the screen's pixel density.
local dpi = Screen.dpi
print("Screen DPI: " .. dpi)
Controls whether the game is displayed in fullscreen mode. When set to true
, the game occupies the entire screen.
Screen.fullScreen = true
Gives a rectangle excluding certain areas of the screen like notches or taskbars. Can be used to adjust the game's layout based on the safe area.
local safeArea = Screen.safeArea
print("Safe area: " .. safeArea)
Sets a timeout after which the device's screen will go to sleep.
Screen.sleepTimeout = 0
Adjusts the brightness of the game screen. The value ranges from 0 to 1, where 0 is the darkest and 1 is the brightest.
Screen.brightness = 0.5