• Functions and constants to access the window, window event listeners and screen dimming.

Static methods

@:native("get_dim_mode")staticgetDimMode():WindowDimmingMode

  • Returns the current dimming mode set on a mobile device.

The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction.

On platforms that does not support dimming, DIMMING_UNKNOWN is always returned.

Returns:

The mode for screen dimming

@:native("get_display_scale")staticgetDisplayScale():Float

  • This returns the content scale of the current display.

Returns:

The display scale

@:native("get_mouse_lock")staticgetMouseLock():Bool

  • This returns the current lock state of the mouse cursor.

Returns:

The lock state

@:native("get_size")staticgetSize():WindowSize

  • This returns the current window size (width and height).

Returns:

The size of the window.

@:native("set_dim_mode")staticsetDimMode(mode:WindowDimmingMode):Void

  • Sets the dimming mode on a mobile device.

The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction. The dimming mode will only affect the mobile device while the game is in focus on the device, but not when the game is running in the background.

This function has no effect on platforms that does not support dimming.

Parameters:

mode

The mode for screen dimming

@:has_untypedstaticinlinesetListener(callback:(event:WindowEvent, data:WindowEventData) ‑> Void):Void

  • Sets a window event listener.

Parameters:

callback

A callback which receives info about window events. Can be null.

@:native("set_mouse_lock")staticsetMouseLock(flag:Bool):Void

  • Set the locking state for current mouse cursor on a PC platform. This function locks or unlocks the mouse cursor to the center point of the window. While the cursor is locked, mouse position updates will still be sent to the scripts as usual.

Parameters:

flag

The lock state for the mouse cursor

@:native("set_position")staticsetPosition(x:Int, y:Int):Void

  • Sets the window position.

Parameters:

x

Horizontal position of window

y

Vertical position of window

@:native("set_size")staticsetSize(width:Int, height:Int):Void

  • Sets the window size. Works on desktop platforms only.

Parameters:

width

Width of window

height

Height of window

@:native("set_title")staticsetTitle(title:String):Void

  • Sets the window title. Works on desktop platforms.

Parameters:

title

The window title (UTF-8)