Skip to main content

FlixelWindow

View source

interface

org.flixelgdx.backend.FlixelWindow

public interface FlixelWindow extends FlixelShakeable

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()

public default float getShakeX()

Current shake channel X (for example graphic offset or world X).


getShakeY()

public default float getShakeY()

Current shake channel Y.


setShake(float, float)

public default void setShake(float x, float y)

Sets the shake channel to absolute coordinates (typically base plus jitter).


getShakeWidth()

public default float 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()

public default float 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()

public default boolean 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)

public default void setTransparencyActive(boolean active)

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:

NameDescription
activetrue to composite with the desktop through alpha; false for a normal opaque window interior.

isTransparencyActive()

public default boolean isTransparencyActive()

Returns: last value applied by FlixelWindow.setTransparencyActive(boolean) for this game session.


getOpacity()

public default float getOpacity()

Returns: The current opacity level of the game's window.


setOpacity(float)

public default void setOpacity(float opacity)

Sets whole-window opacity where the backend supports it (GLFW 3.4+, LWJGL3 desktop).

Parameters:

NameDescription
opacityOpacity in [0, 1]; non-finite values are ignored.

supportsWindowOpacity()

public boolean supportsWindowOpacity()

Returns: true if FlixelWindow.setOpacity(float) can affect the window on this session.


setDecorated(boolean)

public default void setDecorated(boolean decorated)

Sets whether the window uses native title bar and border decorations, when supported.

Parameters:

NameDescription
decoratedfalse for a borderless window.

supportsDecorated()

public default boolean supportsDecorated()

Returns: true if FlixelWindow.setDecorated(boolean) is supported on this session.


getX()

public default int getX()

Window X position in screen coordinates, when supported.

Returns: horizontal position, or 0 when unknown.


getY()

public default int getY()

Window Y position in screen coordinates, when supported.

Returns: vertical position, or 0 when unknown.


setX(int)

public default void setX(int x)

Sets the window's X position in screen coordinates, when supported.

Parameters:

NameDescription
xTarget X in screen coordinates.

setY(int)

public default void setY(int y)

Sets the window's Y position in screen coordinates, when supported.

Parameters:

NameDescription
yTarget Y in screen coordinates.

setPosition(int, int)

public default void setPosition(int x, int y)

Moves the window so its client area origin is placed at the given screen coordinates, when supported.

Parameters:

NameDescription
xTarget X in screen coordinates.
yTarget Y in screen coordinates.

changeX(int)

public default void changeX(int deltaX)

Moves the window horizontally by a delta in screen pixels.

Parameters:

NameDescription
deltaXPixels to add to the current X position (negative values move left).

changeY(int)

public default void changeY(int deltaY)

Moves the window vertically by a delta in screen pixels.

Parameters:

NameDescription
deltaYPixels to add to the current Y position (negative values move up on backends that use upper-left origin).

bringToForeground()

public default void 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()

public default boolean supportsBringToForeground()

Returns: true if FlixelWindow.bringToForeground() can run on this session.


setFloating(boolean)

public default void setFloating(boolean floating)

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:

NameDescription
floatingtrue to keep the window above normal stacking, false for default stacking.

supportsFloating()

public default boolean supportsFloating()

Returns: true if FlixelWindow.setFloating(boolean) may take effect on this session.


setAbsorbCloseRequests(boolean)

public default void setAbsorbCloseRequests(boolean absorb)

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:

NameDescription
absorbtrue to cancel the default close handling from the windowing system.

supportsAbsorbCloseRequests()

public default boolean supportsAbsorbCloseRequests()

Returns: true if FlixelWindow.setAbsorbCloseRequests(boolean) is wired for this session.


isAbsorbCloseRequests()

public default boolean isAbsorbCloseRequests()

Returns: true while close absorption is enabled and the listener chain is active. When FlixelWindow.supportsAbsorbCloseRequests() is false, this is always false.


isFloating()

public default boolean isFloating()

Returns: true when the window is currently floating (always on top), if the backend can query it. When unsupported, returns false.


isDecorated()

public default boolean 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.