diff --git a/docs/maps/api-reference.md b/docs/maps/api-reference.md index 889ed3ac..30d0f1ea 100644 --- a/docs/maps/api-reference.md +++ b/docs/maps/api-reference.md @@ -258,7 +258,7 @@ WA.hideLayer('bottom'); WA.setProperty(layerName : string, propertyName : string, propertyValue : string | number | boolean | undefined) : void; ``` -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". +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`. Example : @@ -266,12 +266,12 @@ Example : WA.setProperty('wikiLayer', 'openWebsite', 'https://www.wikipedia.org/'); ``` -### Listen player movement +### Listen to player movement ``` onPlayerMove(callback: HasPlayerMovedEventCallback): void; ``` -Listens to the movement of the current user and calls the callback. Send a event when current user stop moving, change direction and every 200ms when moving in the same direction. +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. @@ -281,7 +281,7 @@ The event has the following attributes : **callback:** the function that will be called when the current player is moving. It contains the event. -Exemple : +Example : ```javascript WA.onPlayerMove(console.log); ``` @@ -292,7 +292,7 @@ WA.onPlayerMove(console.log); getMap(): Promise ``` -Return a promise of an ITiledMap that contains the JSON file of the map plus the property set by a script. +Returns a promise that resolves to the JSON file of the map. Please note that if you modified the map (for instance by calling `WA.setProperty`, the data returned by `getMap` will contain those changes. Example : ```javascript @@ -360,23 +360,20 @@ WA.getStartLayerName().then((starLayerName) => {console.log(starLayerName)}); ``` registerMenuCommand(commandDescriptor: string, callback: (commandDescriptor: string) => void) ``` -Add a custom menu named "commandDescriptor" in the menu that call the callback when clicked. +Add a custom menu item containing the text `commandDescriptor`. A click on the menu will trigger the `callback`. Example : ```javascript -let chatbotEnabled = false -WA.registerMenuCommand('help', () => { - chatbotEnabled = true; - WA.onChatMessage ... +WA.registerMenuCommand('About', () => { + console.log("The About menu was clicked"); }); -``` ### Getting the list of tags of the current user ``` getTagUser(): Promise ``` -Return the list of all the tags that has the current user. If the current user has no tag, return an empty list. If there is no connection with the room, return nothing. +Returns the tags of the current user. If the current user has no tag, returns an empty list. Example : ```javascript @@ -384,4 +381,3 @@ WA.getTagUser().then((tagList) => { ... }); ``` - diff --git a/front/src/Api/Events/GameStateEvent.ts b/front/src/Api/Events/GameStateEvent.ts index 704cd962..85fb37e9 100644 --- a/front/src/Api/Events/GameStateEvent.ts +++ b/front/src/Api/Events/GameStateEvent.ts @@ -10,6 +10,6 @@ export const isGameStateEvent = tags : tg.isArray(tg.isString), }).get(); /** - * A message sent from the game to the iFrame when the gameState is got by the script + * A message sent from the game to the iFrame when the gameState is received by the script */ -export type GameStateEvent = tg.GuardedType; \ No newline at end of file +export type GameStateEvent = tg.GuardedType; diff --git a/front/src/Api/Events/HasPlayerMovedEvent.ts b/front/src/Api/Events/HasPlayerMovedEvent.ts index 5fe2a1e2..50f017df 100644 --- a/front/src/Api/Events/HasPlayerMovedEvent.ts +++ b/front/src/Api/Events/HasPlayerMovedEvent.ts @@ -11,7 +11,7 @@ export const isHasPlayerMovedEvent = }).get(); /** - * A message sent from the game to the iFrame when the player move after the iFrame send a message to the game that it want to listen to the position of the player + * A message sent from the game to the iFrame to notify a movement from the current player. */ export type HasPlayerMovedEvent = tg.GuardedType; diff --git a/front/src/Phaser/Game/GameMap.ts b/front/src/Phaser/Game/GameMap.ts index d63a67e0..cc109751 100644 --- a/front/src/Phaser/Game/GameMap.ts +++ b/front/src/Phaser/Game/GameMap.ts @@ -117,41 +117,14 @@ export class GameMap { } public findLayer(layerName: string): ITiledMapLayer | undefined { - let i = 0; - let found = false; - while (!found && i layer.name = layerName); } public findPhaserLayer(layerName: string): TilemapLayer | undefined { - let i = 0; - let found = false; - while (!found && i layer.layer.name = layerName); } public addTerrain(terrain : Phaser.Tilemaps.Tileset): void { - console.log('Add'); for (const phaserLayer of this.phaserLayers) { phaserLayer.tileset.push(terrain); }