Added game events
@@ -15,7 +15,7 @@ Controller.call(action, mode, intensity?);
|
||||
| Argument | Type | Description |
|
||||
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- |
|
||||
| action | "left" / "right" / "up" / "down" / "upleft" / "upright" / "downleft" / "downright" / "start" / "select" / "back" / "identify" | The action to send. |
|
||||
| mode | "on" / "off" | The ID of the controller. |
|
||||
| mode | "on" / "off" | The mode of the action. |
|
||||
| (Optional) intensity | number | The intensity of the button press (between 0 and 1). |
|
||||
|
||||
### callCustom
|
||||
|
||||
@@ -112,3 +112,73 @@ Game.getPlayers();
|
||||
**Return** [GamePlayer](./ModuleServerAPIGameLibGamePlayer)[] _GamePlayer instances._
|
||||
|
||||
## Events
|
||||
|
||||
### on: playerJoinGame
|
||||
|
||||
Triggers when a player joins the game.
|
||||
|
||||
```javascript
|
||||
Game.on('playerJoinGame', (player) => {});
|
||||
```
|
||||
|
||||
| Argument | Type | Description |
|
||||
| -------- | ------------------------------------------------ | -------------------------------- |
|
||||
| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that joined the game. |
|
||||
|
||||
### on: playerLeaveGame
|
||||
|
||||
Triggers when a player leaves the game.
|
||||
|
||||
```javascript
|
||||
Game.on('playerLeaveGame', (player) => {});
|
||||
```
|
||||
|
||||
| Argument | Type | Description |
|
||||
| -------- | ------------------------------------------------ | -------------------------------- |
|
||||
| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that leaved the game. |
|
||||
|
||||
### on: gameStart
|
||||
|
||||
Triggers when the game starts.
|
||||
|
||||
```javascript
|
||||
Game.on('gameStart', () => {});
|
||||
```
|
||||
|
||||
### on: gameStop
|
||||
|
||||
Triggers when the game stops.
|
||||
|
||||
```javascript
|
||||
Game.on('gameStop', () => {});
|
||||
```
|
||||
|
||||
### on: action
|
||||
|
||||
Receive actions from a players controller.
|
||||
|
||||
```javascript
|
||||
Game.on('action', (player, action, mode, intensity?) => {});
|
||||
```
|
||||
|
||||
| Argument | Type | Description |
|
||||
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
|
||||
| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that leaved the game. |
|
||||
| action | "left" / "right" / "up" / "down" / "upleft" / "upright" / "downleft" / "downright" / "start" / "select" / "back" / "identify" | The received action. |
|
||||
| mode | "on" / "off" | The mode of the action. |
|
||||
| (Optional) intensity | number | \*_Only when control is analog._ The intensity of the action. |
|
||||
|
||||
### on: customAction
|
||||
|
||||
Receive custom from for a players controller.
|
||||
|
||||
```javascript
|
||||
Game.on('customAction', (player, action, mode, intensity?) => {});
|
||||
```
|
||||
|
||||
| Argument | Type | Description |
|
||||
| -------------------- | ------------------------------------------------ | ------------------------------------------------------------- |
|
||||
| player | [GamePlayer](./ModuleServerAPIGameLibGamePlayer) | The player that leaved the game. |
|
||||
| action | string | The received action. |
|
||||
| mode | "on" / "off" | The mode of the action. |
|
||||
| (Optional) intensity | number | \*_Only when control is analog._ The intensity of the action. |
|
||||
|
||||
Reference in New Issue
Block a user