DecayKnowledgebase
Host typegenerated

Pointer

The mouse, or a finger on a touch screen, handled the same way so one game works on both.

17 members · engine 0.1.0

  • Pointer.delta: Vec2Read-only Vec2 mouse displacement accumulated for this fixed step: positive right and down. Unlocked input uses viewport pixels; captured input uses native raw device counts or browser physical pixels. First arrival/re-entry adds no displacement; the next step reads zero without movement. This is displacement, not velocity: do not multiply by dt. Touch uses Gesture.drag_x/drag_y. Use lock/unlock to request cursor capture and locked to read actual host state.
  • Pointer.inside: boolWhether the mouse is over the game or a finger is on the screen. Check this before trusting a position.
  • Pointer.is_down(button: String) -> boolWhether a mouse button, "Left", "Middle" or "Right", is held. A finger on the screen counts as "Left".
  • Pointer.just_pressed(button: String) -> boolWhether a mouse button was pressed this frame.
  • Pointer.just_released(button: String) -> boolWhether a mouse button was let go this frame, or the last finger lifted.
  • Pointer.lock() -> unitRequests cursor capture from the windowed host. Call after a player click in a browser; capture is asynchronous and may be denied. Read locked for actual state.
  • Pointer.locked: boolRead-only actual host cursor capture state, not the last request. False in headless runs and hosts without capture support.
  • Pointer.over_ui: boolWhether the pointer is over part of the interface, such as a button. Check it so clicking a button does not also shoot or move in the game.
  • Pointer.overlay: Vec2The pointer's position in screen units, where 0 is the centre of the screen and the screen is 2 units tall. The same on any screen size.
  • Pointer.overlay_x: numberThe pointer's sideways position in screen units, where 0 is the centre.
  • Pointer.overlay_y: numberThe pointer's up-down position in screen units, where 0 is the centre.
  • Pointer.position: Vec2The pointer's position in pixels, from the top-left corner of the game's view.
  • Pointer.ray_direction: Vec3Read-only unit Vec3 the world camera's ray through the pointer travels along: straight into the screen for an orthographic camera, through the pointer's pixel for a perspective one. Zero, with ray_origin, when there is no pointer or no world camera, so check its length before using it.
  • Pointer.ray_origin: Vec3Read-only Vec3 where the world camera's ray through the pointer starts, in world space: with ray_direction, what a game casts against its own ground to learn which cell or object the pointer is over, when that ground is not a voxel world Aim can answer for. Zero when there is no pointer or no world camera.
  • Pointer.unlock() -> unitRequests cursor release. Escape, focus loss and suspension also release capture; no automatic recapture.
  • Pointer.x: numberThe pointer's distance from the left edge of the game's view, in pixels.
  • Pointer.y: numberThe pointer's distance from the top edge of the game's view, in pixels.
Source
docs/generated/decay-api.json
Schema
v1
Engine version
0.1.0
Source commit
909aca81368b