Replace the enter/leave zone by enter/leave layer on doc
This commit is contained in:
parent
f4df12e5ff
commit
db82ae4b88
2 changed files with 31 additions and 38 deletions
|
@ -17,35 +17,27 @@ The name of the layers of this map are :
|
|||
* `bottom/build/carpet`
|
||||
* `wall`
|
||||
|
||||
### Detecting when the user enters/leaves a zone
|
||||
### Detecting when the user enters/leaves a layer
|
||||
|
||||
```
|
||||
WA.room.onEnterZone(name: string, callback: () => void): void
|
||||
WA.room.onLeaveZone(name: string, callback: () => void): void
|
||||
WA.room.onEnterLayer(name: string): Subscription
|
||||
WA.room.onLeaveLayer(name: string): Subscription
|
||||
```
|
||||
|
||||
Listens to the position of the current user. The event is triggered when the user enters or leaves a given zone. The name of the zone is stored in the map, on a dedicated layer with the `zone` property.
|
||||
Listens to the position of the current user. The event is triggered when the user enters or leaves a given layer.
|
||||
|
||||
<div>
|
||||
<figure class="figure">
|
||||
<img src="images/trigger_event.png" class="figure-img img-fluid rounded" alt="" />
|
||||
<figcaption class="figure-caption">The `zone` property, applied on a layer</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
* **name**: the name of the zone, as defined in the `zone` property.
|
||||
* **callback**: the function that will be called when a user enters or leaves the zone.
|
||||
* **name**: the name of the layer who as defined in Tiled.
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
WA.room.onEnterZone('myZone', () => {
|
||||
WA.room.onEnterLayer('myLayer').subscribe(() => {
|
||||
WA.chat.sendChatMessage("Hello!", 'Mr Robot');
|
||||
})
|
||||
});
|
||||
|
||||
WA.room.onLeaveZone('myZone', () => {
|
||||
WA.room.onLeaveLayer('myLayer').subscribe(() => {
|
||||
WA.chat.sendChatMessage("Goodbye!", 'Mr Robot');
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
### Show / Hide a layer
|
||||
|
@ -71,7 +63,7 @@ WA.room.setProperty(layerName : string, propertyName : string, propertyValue : s
|
|||
|
||||
Set the value of the `propertyName` property of the layer `layerName` at `propertyValue`. If the property doesn't exist, create the property `propertyName` and set the value of the property at `propertyValue`.
|
||||
|
||||
Note :
|
||||
Note :
|
||||
To unset a property from a layer, use `setProperty` with `propertyValue` set to `undefined`.
|
||||
|
||||
Example :
|
||||
|
@ -131,7 +123,7 @@ console.log("Map generated with Tiled version ", map.tiledversion);
|
|||
|
||||
Check the [Tiled documentation to learn more about the format of the JSON map](https://doc.mapeditor.org/en/stable/reference/json-map-format/).
|
||||
|
||||
### Changing tiles
|
||||
### Changing tiles
|
||||
```
|
||||
WA.room.setTiles(tiles: TileDescriptor[]): void
|
||||
```
|
||||
|
@ -144,7 +136,7 @@ If `tile` is a string, it's not the id of the tile but the value of the property
|
|||
</div>
|
||||
</div>
|
||||
|
||||
`TileDescriptor` has the following attributes :
|
||||
`TileDescriptor` has the following attributes :
|
||||
* **x (number) :** The coordinate x of the tile that you want to replace.
|
||||
* **y (number) :** The coordinate y of the tile that you want to replace.
|
||||
* **tile (number | string) :** The id of the tile that will be placed in the map.
|
||||
|
@ -154,7 +146,7 @@ If `tile` is a string, it's not the id of the tile but the value of the property
|
|||
|
||||
Note: If you want to unset a tile, use `setTiles` with `tile` set to `null`.
|
||||
|
||||
Example :
|
||||
Example :
|
||||
```javascript
|
||||
WA.room.setTiles([
|
||||
{x: 6, y: 4, tile: 'blue', layer: 'setTiles'},
|
||||
|
@ -246,7 +238,7 @@ const website = WA.room.website.create({
|
|||
WA.room.website.delete(name: string): Promise<void>
|
||||
```
|
||||
|
||||
Use `WA.room.website.delete` to completely remove an embedded website from your map.
|
||||
Use `WA.room.website.delete` to completely remove an embedded website from your map.
|
||||
|
||||
|
||||
### The EmbeddedWebsite class
|
||||
|
@ -271,7 +263,7 @@ When you modify a property of an `EmbeddedWebsite` instance, the iframe is autom
|
|||
|
||||
|
||||
{.alert.alert-warning}
|
||||
The websites you add/edit/delete via the scripting API are only shown locally. If you want them
|
||||
The websites you add/edit/delete via the scripting API are only shown locally. If you want them
|
||||
to be displayed for every player, you can use [variables](api-start.md) to share a common state
|
||||
between all users.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue