Input
Handles game mouse and keyboard input
Constructor Summary
Public Constructor | ||
public |
constructor(game: Game) Default constructor |
Member Summary
Public Members | ||
public |
A reference to the Chat class |
|
public |
An instance of the client |
|
public |
The cursor |
|
public |
Whether or not the cursor is visible |
|
public |
All loaded cursors |
|
public |
An instance of the game |
|
public |
The entity being hovered over |
|
public |
A moving target's color |
|
public |
Information about the mouse position |
|
public |
A new instance of the cursor (for changing cursors) |
|
public |
The new target color |
|
public |
A reference to the overlay handler |
|
public |
previousClick: MouseEvent The previous mouse click envent |
|
public |
previousKey: KeyboardEvent The previous key pressed |
|
public |
An instance of the game renderer |
|
public |
Whether or not the selected cell is visible |
|
public |
The select x position |
|
public |
The select y position |
|
public |
This is the animation for the target cell spinner sprite (only on desktop) |
|
public |
The color of the target |
|
public |
Data on the targeted entity |
|
public |
Whether or not the target is visible |
Method Summary
Public Methods | ||
public |
Handle clicking events |
|
public |
Returns the interface actions |
|
public |
Get an attack cursor (bow or sword) depending on if the player is ranged or not |
|
public |
Get the coordinates from the mouse relative to the canvas grid |
|
public |
Returns an instance of the player |
|
public |
getTargetData(): { sprite: Sprite, x: Number, y: Number, width: Number, height: Number, dy: Number, dw: Number, dh: Number, } Get data about the current target |
|
public |
Handle input |
|
public |
isAttackable(entity: Entity): Boolean Returns whether or not the player can attack this entity |
|
public |
isTargetable(entity: Entity): Boolean Returns whether or not this entity can be targeted |
|
public |
Handle key presses to move the player in a direction |
|
public |
Handle keyUp events |
|
public |
Load cursors |
|
public |
Load spinner sprite, chat handler and overlay |
|
public |
Move the cursor or display a different cursor depending on what the player is hovering over |
|
public |
Set an attack target |
|
public |
setCoords(event: MouseEvent) Sets the coordinates of the mouse relative to the offset of the canvas |
|
public |
setCursor(cursor: Cusror) Set a new cursor |
|
public |
Set a passive target |
|
public |
setPosition(x: Number, y: Number) Set the selectedX and selectedY positions |
|
public |
Change the cursor if visible and newCursor doesn't equal cursor |
Public Constructors
Public Members
public targetAnimation: * source
This is the animation for the target cell spinner sprite (only on desktop)
Public Methods
public click(position: Object) source
Handle clicking events
Params:
Name | Type | Attribute | Description |
position | Object | the x,y coordinates of the click position |
public getAttackCursor(): Cursor source
Get an attack cursor (bow or sword) depending on if the player is ranged or not
public getCoords(): {x: Number, y: Number} source
Get the coordinates from the mouse relative to the canvas grid
public getTargetData(): { sprite: Sprite, x: Number, y: Number, width: Number, height: Number, dy: Number, dw: Number, dh: Number, } source
Get data about the current target
Return:
{ sprite: Sprite, x: Number, y: Number, width: Number, height: Number, dy: Number, dw: Number, dh: Number, } | target data |
public isAttackable(entity: Entity): Boolean source
Returns whether or not the player can attack this entity
Params:
Name | Type | Attribute | Description |
entity | Entity | the entity they want to attack |
public isTargetable(entity: Entity): Boolean source
Returns whether or not this entity can be targeted
Params:
Name | Type | Attribute | Description |
entity | Entity | the entity to check if it can be targeted or not |
public keyMove(position: Object) source
Handle key presses to move the player in a direction
Params:
Name | Type | Attribute | Description |
position | Object | The x,y coordinates of the click position |
public keyUp(key: Modules) source
Handle keyUp events
Params:
Name | Type | Attribute | Description |
key | Modules | the Modules.Keys that was triggered |
public moveCursor() source
Move the cursor or display a different cursor depending on what the player is hovering over
public setCoords(event: MouseEvent) source
Sets the coordinates of the mouse relative to the offset of the canvas
Params:
Name | Type | Attribute | Description |
event | MouseEvent | the mouse move or mouse click event |
public setCursor(cursor: Cusror) source
Set a new cursor
Params:
Name | Type | Attribute | Description |
cursor | Cusror | the cursor to use |