Skip to main content

FlixelMouseManager

View source

class

org.flixelgdx.input.mouse.FlixelMouseManager

public class FlixelMouseManager implements FlixelInputProcessorManager

Mouse and pointer polling with screen/world coordinates. Access via Flixel.mouse after Flixel.initialize(FlixelGame).

Scroll wheel deltas

InputProcessor.scrolled(...) supplies amountX and amountY from libGDX. This manager accumulates them into FlixelMouseManager.getScrollDeltaX() and FlixelMouseManager.getScrollDeltaY() until FlixelMouseManager.endFrame().

  • FlixelMouseManager.getScrollDeltaX(): horizontal scroll (e.g. trackpad sideways, some Shift+wheel setups). Not the usual mouse-wheel up/down axis. This is typically used by trackpad users for horizontal scrolling.
  • FlixelMouseManager.getScrollDeltaY(): vertical scroll. This is what you normally use for standard wheel up/down. You'll most likely use this a lot of the time.

Values are deltas, not fixed -1/1: magnitude varies by device (notched wheel vs trackpad, high-resolution wheels). The sign indicates direction, but which sign means "up" vs "down" can depend on the backend/OS; verify on your target platform if input feels inverted.

Read accumulated scroll after FlixelMouseManager.update() and before FlixelMouseManager.endFrame() clears it (same timing as other per-frame input you consume in your game loop).

Constructors

FlixelMouseManager()

public FlixelMouseManager()

Fields

icons

public FlixelMouseIconManager icons

enabled

public boolean enabled

When false, all queries return inactive state.


Methods

setMouseIconManager(FlixelMouseIconManager)

public void setMouseIconManager(FlixelMouseIconManager iconManager)

Replaces the active FlixelMouseIconManager, for example with an LWJGL3 or web backend. Pass null to force the shared no-op implementation.

Parameters:

NameDescription
iconManagerThe FlixelMouseIconManager to implement.

getInputProcessor()

public InputProcessor getInputProcessor()

update()

public void update()

Call once per frame at the start of the game update (with Flixel.keys).


setWorldCamera(FlixelCamera)

public void setWorldCamera(FlixelCamera worldCamera)

Sets the camera for world coordinates; null uses Flixel.cameras.


getWorldCamera()

public FlixelCamera getWorldCamera()

endFrame()

public void endFrame()

Call at end of frame after game logic (with FlixelKeyInputManager.endFrame()). Resets FlixelMouseManager.getScrollDeltaX() and FlixelMouseManager.getScrollDeltaY() to zero for the next frame.


getScreenX()

public int getScreenX()

getScreenY()

public int getScreenY()

getWorldX()

public float getWorldX()

getWorldY()

public float getWorldY()

getWorldX(FlixelCamera)

public float getWorldX(FlixelCamera cam)

getWorldY(FlixelCamera)

public float getWorldY(FlixelCamera cam)

getScrollDeltaX()

public float getScrollDeltaX()

Sum of horizontal scroll amounts received this frame via InputProcessor.scrolled(...) amountX (not cleared until FlixelMouseManager.endFrame()). Use for sideways scroll; for typical wheel up/down use FlixelMouseManager.getScrollDeltaY().


getScrollDeltaY()

public float getScrollDeltaY()

Sum of vertical scroll amounts received this frame via InputProcessor.scrolled(...) amountY (not cleared until FlixelMouseManager.endFrame()). Sign and magnitude are device-dependent; see class Javadoc.


pressed(int)

public boolean pressed(int button)

Returns whether the given mouse button is held down. Returns false while the active debug overlay reports that another UI layer (typically the imgui debugger) is capturing mouse input, so clicking inside an imgui window cannot leak into game logic.

Use FlixelMouseManager.rawPressed(int) when you specifically need the raw, unsuppressed state. The debug overlay's own sprite picker / camera tools use the raw variants so they can opt in to "ignore the suppression" when needed.

Parameters:

NameDescription
buttonlibGDX button index (e.g. 0 for left mouse button).

Returns: true if the button is pressed and input is enabled and not suppressed by UI.


rawPressed(int)

public boolean rawPressed(int button)

Same as FlixelMouseManager.pressed(int) but bypasses the "captured by debug UI" check.

Parameters:

NameDescription
buttonlibGDX button index.

Returns: true if the button is pressed and input is enabled, regardless of UI capture.


justPressed(int)

public boolean justPressed(int button)

Returns whether the given mouse button was just pressed this frame. Returns false while the debug UI reports that another UI layer is capturing mouse input.

Parameters:

NameDescription
buttonlibGDX button index.

Returns: true if the button was just pressed and input is enabled and not suppressed.


rawJustPressed(int)

public boolean rawJustPressed(int button)

Same as FlixelMouseManager.justPressed(int) but bypasses the "captured by debug UI" check.

Parameters:

NameDescription
buttonlibGDX button index.

Returns: true if the button was just pressed and input is enabled, regardless of UI capture.


justReleased(int)

public boolean justReleased(int button)

Returns whether the given mouse button was just released this frame. Returns false while the debug UI reports that another UI layer is capturing mouse input.

Parameters:

NameDescription
buttonlibGDX button index.

Returns: true if the button was just released and input is enabled and not suppressed.


rawJustReleased(int)

public boolean rawJustReleased(int button)

Same as FlixelMouseManager.justReleased(int) but bypasses the "captured by debug UI" check.

Parameters:

NameDescription
buttonlibGDX button index.

Returns: true if the button was just released and input is enabled, regardless of UI capture.


overlap(FlixelPositional)

public boolean overlap(FlixelPositional obj)