Skip to main content

FlixelTouch

View source

class

org.flixelgdx.input.touch.FlixelTouch

public final class FlixelTouch

State snapshot for a single touch pointer (one finger).

Instances are pre-allocated by FlixelTouchManager and reused across frames; do not create them yourself. Access the array via FlixelTouchManager.list:

FlixelTouch first = Flixel.touches.list[0];
if (first.isJustPressed()) {
spawnEffect(first.worldX, first.worldY);
}

Screen coordinates use libGDX's top-left origin (Y increases downward). World coordinates are unprojected via the touch manager's active camera and use the standard bottom-left origin (Y increases upward), matching the rest of the scene.

State fields (FlixelTouch.screenX, FlixelTouch.screenY, FlixelTouch.worldX, FlixelTouch.worldY, FlixelTouch.pointer) are public for zero-overhead reads. The boolean state is exposed through getters to prevent accidental modification by game code; the manager is the only writer.

See Also: FlixelTouchManager

Fields

worldX

public float worldX

World X coordinate of this pointer, unprojected from screen space via the active camera.


worldY

public float worldY

World Y coordinate of this pointer, unprojected from screen space via the active camera.


screenX

public int screenX

Screen X coordinate in pixels, top-left origin, matching libGDX conventions.


screenY

public int screenY

Screen Y coordinate in pixels, top-left origin, matching libGDX conventions.


pointer

public int pointer

Zero-based pointer index identifying this finger (0 = first touch, 1 = second, etc.).


Methods

pressed()

public boolean pressed()

Returns true while this pointer is currently in contact with the screen.


justPressed()

public boolean justPressed()

Returns true on the single frame this pointer first touched the screen. Clears to false after FlixelTouchManager.endFrame() is called.


justReleased()

public boolean justReleased()

Returns true on the single frame this pointer lifted off the screen. Clears to false after FlixelTouchManager.endFrame() is called.


dragging()

public boolean dragging()

Returns true once this pointer has moved after being pressed, and stays true until the pointer is released. Use this to distinguish a tap from a drag gesture.


justCancelled()

public boolean justCancelled()

Returns true on the single frame this pointer was cancelled by the system (for example, an incoming phone call interrupting the touch session). Clears to false after FlixelTouchManager.endFrame() is called.