Skip to main content

Class: InputSystem

Defined in: input/systems/input-system.ts:11

The InputSystem class. It tracks key presses, mouse button presses, mouse coordinates, and scroll delta values.

Extends

Constructors

Constructor

new InputSystem(gameContainer, cameraEntity, screenWidth, screenHeight): InputSystem

Defined in: input/systems/input-system.ts:33

Constructs a new instance of the InputSystem class and sets up event listeners for various input events.

Parameters

gameContainer

HTMLElement

The HTML element that contains the game.

cameraEntity

Entity

screenWidth

number

screenHeight

number

Returns

InputSystem

Overrides

System.constructor

Properties

isEnabled

isEnabled: boolean = true

Defined in: ecs/types/System.ts:24

Indicates whether the system is enabled.

Inherited from

System.isEnabled


name

name: string

Defined in: ecs/types/System.ts:14

The name of the system.

Inherited from

System.name


query

query: Query

Defined in: ecs/types/System.ts:19

The components that this system operates on.

Inherited from

System.query

Methods

beforeAll()

beforeAll(entities): Entity[]

Defined in: ecs/types/System.ts:70

Hook method that is called before running the system on all entities. Can be overridden by subclasses to modify the entities before processing.

Parameters

entities

Entity[]

The entities to be processed.

Returns

Entity[]

The modified entities.

Inherited from

System.beforeAll


clearInputs()

clearInputs(): void

Defined in: input/systems/input-system.ts:122

Clears the current input states.

Returns

void


onKeyDownHandler()

onKeyDownHandler(event): void

Defined in: input/systems/input-system.ts:152

Handles the key down event, updating the key press and key down states.

Parameters

event

KeyboardEvent

The keyboard event.

Returns

void


onKeyUpHandler()

onKeyUpHandler(event): void

Defined in: input/systems/input-system.ts:143

Handles the key up event, updating the key press and key up states.

Parameters

event

KeyboardEvent

The keyboard event.

Returns

void


onMouseDownHandler()

onMouseDownHandler(event): void

Defined in: input/systems/input-system.ts:182

Handles the mouse down event, updating the mouse button press and mouse button down states.

Parameters

event

MouseEvent

The mouse event.

Returns

void


onMouseUpHandler()

onMouseUpHandler(event): void

Defined in: input/systems/input-system.ts:191

Handles the mouse up event, updating the mouse button press and mouse button up states.

Parameters

event

MouseEvent

The mouse event.

Returns

void


onWheelEventHandler()

onWheelEventHandler(event): void

Defined in: input/systems/input-system.ts:134

Handles the wheel event, updating the scroll delta value.

Parameters

event

WheelEvent

The wheel event.

Returns

void


run()

run(entity): void

Defined in: input/systems/input-system.ts:77

Runs the input system for the given entity, updating its InputsComponent with the current input states.

Parameters

entity

Entity

The entity to update.

Returns

void

Overrides

System.run


runSystem()

runSystem(entities): void

Defined in: ecs/types/System.ts:40

Runs the system on the provided entities.

Parameters

entities

Entity[]

The entities to run the system on.

Returns

void

Inherited from

System.runSystem


stop()

stop(): void

Defined in: input/systems/input-system.ts:98

Stops the input system, removing all event listeners.

Returns

void

Overrides

System.stop


updateCursorPosition()

updateCursorPosition(event): void

Defined in: input/systems/input-system.ts:165

Updates the mouse cursor position.

Parameters

event

MouseEvent

The mouse event.

Returns

void