FlixelWindow
View sourceinterface
org.flixelgdx.backend.FlixelWindow
Desktop window controls that stay safe on every platform.
Use Flixel.window after Flixel.initialize(FlixelGame). The implementation only adjusts backdrop drawing and, on desktop with a transparent-capable framebuffer, an end-of-frame alpha fix so normal gameplay is not composited through the desktop unless this mode is on.
Desktop games default to an alpha-capable framebuffer (see FlixelGame.isTransparentFramebufferRequested()). Call FlixelWindow.setTransparencyActive(boolean) any time to show the real desktop through unused pixels, or turn it back off.
Example:
Flixel.window.setDesktopTransparencyActive(true); // Sprites over the desktop.
// ...
Flixel.window.setDesktopTransparencyActive(false); // Normal opaque letterboxing again.
This interface extends FlixelShakeable so you can pass Flixel.window to FlixelTween.shake when you want the OS window itself to jitter.
See Also: Flixel.window
Methods
getShakeX()
Current shake channel X (for example graphic offset or world X).
getShakeY()
Current shake channel Y.
setShake(float, float)
Sets the shake channel to absolute coordinates (typically base plus jitter).
getShakeWidth()
Width used to scale FlixelShakeUnit.FRACTION on the X axis. Values 0 or less mean the tween treats intensity like plain pixels on that axis.
getShakeHeight()
Height used to scale FlixelShakeUnit.FRACTION on the Y axis. Values 0 or less mean the tween treats intensity like plain pixels on that axis.
isTransparentFramebufferRequested()
When true, the LWJGL3 launcher enables Lwjgl3ApplicationConfiguration#setTransparentFramebuffer(boolean). This is true by default so runtime transparency can work; set false before launch only if you need a classic opaque framebuffer or hit a driver issue (then FlixelWindow.setTransparencyActive(boolean) cannot composite with the desktop).
Returns: current launch-time request for an alpha-capable default framebuffer.
setTransparencyActive(boolean)
Turns desktop-composited transparency on or off.
When true, clears and camera backdrop fills use alpha zero so unchanged pixels show whatever is behind the window (when the framebuffer was created with transparency support). When false, restores backdrop colors cached the first time transparency was enabled this session, or falls back to opaque Color.BLACK if transparency was never enabled.
Parameters:
| Name | Description |
|---|---|
active | true to composite with the desktop through alpha; false for a normal opaque window interior. |
isTransparencyActive()
Returns: last value applied by FlixelWindow.setTransparencyActive(boolean) for this game session.
getOpacity()
Returns: The current opacity level of the game's window.
setOpacity(float)
Sets whole-window opacity where the backend supports it (GLFW 3.4+, LWJGL3 desktop).
Parameters:
| Name | Description |
|---|---|
opacity | Opacity in [0, 1]; non-finite values are ignored. |
supportsWindowOpacity()
Returns: true if FlixelWindow.setOpacity(float) can affect the window on this session.
setDecorated(boolean)
Sets whether the window uses native title bar and border decorations, when supported.
Parameters:
| Name | Description |
|---|---|
decorated | false for a borderless window. |
supportsDecorated()
Returns: true if FlixelWindow.setDecorated(boolean) is supported on this session.
getX()
Window X position in screen coordinates, when supported.
Returns: horizontal position, or 0 when unknown.
getY()
Window Y position in screen coordinates, when supported.
Returns: vertical position, or 0 when unknown.
setX(int)
Sets the window's X position in screen coordinates, when supported.
Parameters:
| Name | Description |
|---|---|
x | Target X in screen coordinates. |
setY(int)
Sets the window's Y position in screen coordinates, when supported.
Parameters:
| Name | Description |
|---|---|
y | Target Y in screen coordinates. |
setPosition(int, int)
Moves the window so its client area origin is placed at the given screen coordinates, when supported.
Parameters:
| Name | Description |
|---|---|
x | Target X in screen coordinates. |
y | Target Y in screen coordinates. |
changeX(int)
Moves the window horizontally by a delta in screen pixels.
Parameters:
| Name | Description |
|---|---|
deltaX | Pixels to add to the current X position (negative values move left). |
changeY(int)
Moves the window vertically by a delta in screen pixels.
Parameters:
| Name | Description |
|---|---|
deltaY | Pixels to add to the current Y position (negative values move up on backends that use upper-left origin). |
bringToForeground()
Asks the OS to focus this game window (desktop only where GLFW allows it).
CAUTION: Pulling focus away from another application is disruptive. It's advised you warn players ahead of time on your store page, in a first-run dialog, or in an in-game settings label before calling this from normal gameplay.
supportsBringToForeground()
Returns: true if FlixelWindow.bringToForeground() can run on this session.
setFloating(boolean)
When true, requests a floating (often "always on top") window using GLFW_FLOATING where the backend supports it.
CAUTION: Keeping the game above everything else can hide important system UI or other apps. Disclose this in plain language before you enable it, and ideally expose a user-visible toggle.
Parameters:
| Name | Description |
|---|---|
floating | true to keep the window above normal stacking, false for default stacking. |
supportsFloating()
Returns: true if FlixelWindow.setFloating(boolean) may take effect on this session.
setAbsorbCloseRequests(boolean)
When true, the GLFW close event is absorbed so the window does not exit until you stop absorbing or call Gdx.app.exit() yourself.
CAUTION: Players expect the window close control to quit. If you absorb close requests, you must explain that ahead of time (splash text, settings, store description) and always provide another obvious way to exit.
Parameters:
| Name | Description |
|---|---|
absorb | true to cancel the default close handling from the windowing system. |
supportsAbsorbCloseRequests()
Returns: true if FlixelWindow.setAbsorbCloseRequests(boolean) is wired for this session.
isAbsorbCloseRequests()
Returns: true while close absorption is enabled and the listener chain is active. When FlixelWindow.supportsAbsorbCloseRequests() is false, this is always false.
isFloating()
Returns: true when the window is currently floating (always on top), if the backend can query it. When unsupported, returns false.
isDecorated()
Returns: true when the window has native decorations (title bar and border), if the backend can query it. When unsupported, returns true so game code treats the common case as decorated.