入力イベント
説明
このライブラリには、さまざまなタイプの入力に対応するイベントが含まれている。
Types
Position
Property | Type | Description |
---|---|---|
x | integer | The x-coordinate in pixels |
y | integer | The y-coordinate in pixels |
UIHoverEvent
Property | Type | Description |
---|---|---|
x | integer | The x-coordinate in pixels |
y | integer | The y-coordinate in pixels |
targets | eid[] | The target UI element(s) |
TouchEvent
Property | Type | Description |
---|---|---|
pointerId | integer | unique ID for the pointer, provided by the browser. |
position | Position | Touched position coordinates in pixels |
worldPosition | Vector3 | The position where the touchedEvent hit in the world. only available on SCREEN_TOUCH_START . |
target | eid | eid if initially touched object |
start | Position | The position coordinates in pixels where the touch event started. |
change | Position | The position coordinates in pixels of the touch since the last change. |
GestureEvent
Property | Type | Description |
---|---|---|
touchCount | integer | The number of points contributing to the gesture. |
position | Position | Touched position coordinates in pixels |
startPosition | Position | The position coordinates in pixels where the event started. |
positionChange | Position | The position coordinates in pixels since the last change. |
spread | float | The average position between pointers from the center point. |
startSpread | float | The first spread emitted in start. |
spreadChange | float | The spread value since the last change. |
nextTouchCount | integer | On end, the number of pointers involved in the following gesture |
Events
UI_CLICK
Emitted when both the press (UI_PRESSED) and release (UI_RELEASED) occur on the same UI element. This event represents a complete click or tap gesture. It is dispatched on the element where both interactions overlapped and is typically used for confirming user intention, such as activating a button or triggering an action. The event will be dispatched on the lowest common ancestor of the start (pressed) and end (released) eids. Mouse movement does not affect click events.
Example
world.events.addListener(component.eid, ecs.input.UI_CLICK, (uiClickEvent: Position) => {
console.log(uiClickEvent);
})