import Pointer from '@mobilizing/library/js/Mobilizing/input/Pointer.js'
Pointer
Extends:
Pointer is an abstraction that enables various input devices to send the same kind of events. It is designed to accumulate various type of inputs in a Map of PointerOject. Each input device is converted in a PointerOject in order to unify its interface. Usefully mainly internally for interactive UI objects like buttons.
Example:
//TODO
Constructor Summary
Public Constructor | ||
public | constructor(params: Object) |
Member Summary
Public Members | ||
public | components: * | |
public | ||
public | pointers: * |
Method Summary
Public Methods | ||
public | Adds the specified input component as a PointerObject to the pointers list. | |
public | addMouse(component: *) | |
public | addTouch(component: *) | |
public | Returns the specified PointerObject to work with its state | |
public | Returns x delta coordinates of the PointerObject (input Component) of the given index. | |
public | Returns y delta coordinates of the PointerObject (input Component) of the given index. | |
public | getPointers(): Array Returns an Array from the pointers Map object. | |
public | Returns true if ANY of the PointerObjects (input Component) state is true, false otherwise. | |
public | Returns x coordinates of the PointerObject (input Component) of the given index. | |
public | Returns y coordinates of the PointerObject (input Component) of the given index. | |
public | Remove unused Pointers |
Inherited Summary
From class Component | ||
public | ||
public | context: * | |
public | events: * | |
public | id: * | |
public | name: * | |
private | _nexts: *[] | |
private | ||
public | byPass() | |
public | Adds a component to this chained component array | |
public | Returns the array of attached children components | |
public | off() Deactivate the component | |
public | on() Activate the component A call to this method calls the setup method if it has not been run yet | |
public | Run code after the update of all components is run This empty method is usually overriden to perform post-update actions for the component It is called periodically by an internal Mobilizing mechanism | |
public | preLoad() preLoad the component This empty method is usually overriden to perform preLoad actions for the component. | |
public | Run code before the update of all components is run This empty method is usually overriden to perform pre-update actions for the component It is called once per component by an internal Mobilizing mechanism | |
public | prepare() prepare the component This empty method is usually overriden to perform preparation actions for the component, from external process as a server. | |
public | setup() Set's up the component This empty method is usually overriden to perform setup actions for the component This is where all the initialization (such as adding event listeners)should be done It is called automatically by an internal Mobilizing mechanism and should thus not be called directly | |
public | update() Update the component This empty method is usually overriden to perform update actions for the component It is called periodically by an internal Mobilizing mechanism |
Public Constructors
public constructor(params: Object) source
Override:
Component#constructorParams:
Name | Type | Attribute | Description |
params | Object | Parameters object, given by the constructor. | |
params.components | [Component] | an array of input components to add to this pointer (i.e. Mouse) |
Public Members
public components: * source
public lastActivePointer: * source
public pointers: * source
Public Methods
public add(component: Component) source
Adds the specified input component as a PointerObject to the pointers list.
Params:
Name | Type | Attribute | Description |
component | Component |
public addMouse(component: *) source
Params:
Name | Type | Attribute | Description |
component | * |
public addTouch(component: *) source
Params:
Name | Type | Attribute | Description |
component | * |
public get(component: Component): Component source
Returns the specified PointerObject to work with its state
Params:
Name | Type | Attribute | Description |
component | Component |
Return:
Component | the corresponding input Component |
public getDeltaX(index: Number): Number source
Returns x delta coordinates of the PointerObject (input Component) of the given index. If no index is given, the last active pointer will return.
Params:
Name | Type | Attribute | Description |
index | Number |
| the pointer object we want to get |
Return:
Number | coordinate |
public getDeltaY(index: Number): Number source
Returns y delta coordinates of the PointerObject (input Component) of the given index. If no index is given, the last active pointer will return.
Params:
Name | Type | Attribute | Description |
index | Number |
| the pointer object we want to get |
Return:
Number | coordinate |
public getPointers(): Array source
Returns an Array from the pointers Map object. For debug purpose.
Return:
Array | Pointers array |
public getState(): Array source
Returns true if ANY of the PointerObjects (input Component) state is true, false otherwise. i.e. if you add a mouse and a touch component to the pointer, this will return true if any of these 2 has it's state to true.
Return:
Array | pointers array |
public getX(index: Number): Number source
Returns x coordinates of the PointerObject (input Component) of the given index. If no index is given, the last active pointer will return.
Params:
Name | Type | Attribute | Description |
index | Number |
| the pointer object we want to get |
Return:
Number | x coordinate |