Mouse.js
MouseManager
Manages the mouse input.
Kind: global class
Constructors:
- MouseManager
- .getPosition() ⇒
Object
- .getWindowPosition() ⇒
Object
- .getNameByButtonCode(buttonCode) ⇒
string
- .getButtonKeyByName(buttonName) ⇒
number
- .isButtonDown(button) ⇒
boolean
- .isButtonDownByName(button) ⇒
boolean
- .isButtonDownByButtonCode(button) ⇒
boolean
- .getPosition() ⇒
MouseManager.getPosition() ⇒ Object
Returns the mouse position relative to the canvas.
Kind: static method of MouseManager
Returns: Object
-
The current mouse position {x, y}
Example
const { x, y } = Impacto.Inputs.Mouse.getPosition();
MouseManager.getWindowPosition() ⇒ Object
Returns the mouse position relative to the window.
Kind: static method of MouseManager
Returns: Object
-
The current mouse position {x, y}
Example
const { x, y } = Impacto.Inputs.Mouse.getWindowPosition();
MouseManager.getNameByButtonCode(buttonCode) ⇒ string
Returns the name of the button by the button code.
Kind: static method of MouseManager
Returns: string
-
The name of the button
Param | Type | Description |
---|---|---|
buttonCode | number | The button code |
Example
console.log(Impacto.Inputs.Mouse.getNameByButtonCode(1)); // "middle"
MouseManager.getButtonKeyByName(buttonName) ⇒ number
Returns the code of the button by the button name.
Kind: static method of MouseManager
Returns: number
-
The button code
Param | Type | Description |
---|---|---|
buttonName | string | The name of the button |
Example
console.log(Impacto.Inputs.Mouse.getButtonCodeByName("left")); // 0
MouseManager.isButtonDown(button) ⇒ boolean
Returns if the button is pressed.
Kind: static method of MouseManager
Returns: boolean
-
True if the button is pressed
Param | Type | Description |
---|---|---|
button | string | number | The button name or code |
Example
Impacto.Inputs.Mouse.isButtonPressed("left") // True
MouseManager.isButtonDownByName(button) ⇒ boolean
Returns if the button is pressed by the button name.
Kind: static method of MouseManager
Returns: boolean
-
True if the button is pressed
Param | Type | Description |
---|---|---|
button | string | number | The button name |
Example
Impacto.Inputs.Mouse.isButtonDownByName("left") // True
MouseManager.isButtonDownByButtonCode(button) ⇒ boolean
Returns if the button is pressed by the button code.
Kind: static method of MouseManager
Returns: boolean
-
True if the button is pressed
Param | Type | Description |
---|---|---|
button | string | number | The button code |
Example
Impacto.Inputs.Mouse.isButtonDownByName(2) // True