Updates documentation
This commit is contained in:
parent
926fcf9d63
commit
1dd07f0ed3
@ -58,6 +58,22 @@ WA.onInit().then(() => {
|
||||
})
|
||||
```
|
||||
|
||||
### Get the position of the player
|
||||
```
|
||||
WA.player.getPosition(): Promise<Position>
|
||||
```
|
||||
The player's current position is available using the `WA.player.getPosition()` function.
|
||||
|
||||
{.alert.alert-info}
|
||||
You need to wait for the end of the initialization before calling `WA.player.getPosition()`
|
||||
|
||||
```typescript
|
||||
WA.onInit().then(() => {
|
||||
console.log('Tags: ', WA.player.getPosition());
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
### Listen to player movement
|
||||
```
|
||||
WA.player.onPlayerMove(callback: HasPlayerMovedEventCallback): void;
|
||||
@ -79,8 +95,8 @@ Example :
|
||||
WA.player.onPlayerMove(console.log);
|
||||
```
|
||||
|
||||
## Player specific properties
|
||||
Similarly to maps (see [API state related functions](api-state.md)), it is possible to store data **related to a specific player** in a "state". Such data will be stored using the local storage from the user's browser.
|
||||
## Player specific variables
|
||||
Similarly to maps (see [API state related functions](api-state.md)), it is possible to store data **related to a specific player** in a "state". Such data will be stored using the local storage from the user's browser. Any value that is serializable in JSON can be stored.
|
||||
|
||||
{.alert.alert-info}
|
||||
In the future, player-related variables will be stored on the WorkAdventure server if the current player is logged.
|
||||
@ -95,10 +111,10 @@ Example:
|
||||
WA.player.state.toto = "value" //will set the "toto" key to "value"
|
||||
```
|
||||
|
||||
### Reading a property
|
||||
A player property can be read by calling its key from the player's state.
|
||||
### Reading a variable
|
||||
A player variable can be read by calling its key from the player's state.
|
||||
|
||||
Example:
|
||||
```javascript
|
||||
WA.player.state.toto //will retrieve the property
|
||||
WA.player.state.toto //will retrieve the variable
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user