New methods refactored
This commit is contained in:
parent
b50df10a49
commit
bdb32a29e1
16 changed files with 246 additions and 141 deletions
21
docs/maps/api-player.md
Normal file
21
docs/maps/api-player.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
{.section-title.accent.text-primary}
|
||||
# API Player functions Reference
|
||||
|
||||
### Listen to player movement
|
||||
```
|
||||
WA.player.onPlayerMove(callback: HasPlayerMovedEventCallback): void;
|
||||
```
|
||||
Listens to the movement of the current user and calls the callback. Sends an event when the user stops moving, changes direction and every 200ms when moving in the same direction.
|
||||
|
||||
The event has the following attributes :
|
||||
* **moving (boolean):** **true** when the current player is moving, **false** otherwise.
|
||||
* **direction (string):** **"right"** | **"left"** | **"down"** | **"top"** the direction where the current player is moving.
|
||||
* **x (number):** coordinate X of the current player.
|
||||
* **y (number):** coordinate Y of the current player.
|
||||
|
||||
**callback:** the function that will be called when the current player is moving. It contains the event.
|
||||
|
||||
Example :
|
||||
```javascript
|
||||
WA.player.onPlayerMove(console.log);
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue