Constructor
new ClientEngine(gameEngine, inputOptions, Renderer)
Create a client engine instance.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
gameEngine |
GameEngine | a game engine |
||||||||||||||||||||||||||||||||||||||||||
inputOptions |
Object | options object Properties
|
||||||||||||||||||||||||||||||||||||||||||
Renderer |
Renderer | the Renderer class constructor |
- Source:
Members
gameEngine :GameEngine
reference to game engine
- Source:
serializer :Serializer
reference to serializer
- Source:
Methods
connect(optionsopt) → {Promise}
Makes a connection to the game server. Extend this method if you want to add additional logic on every connection. Call the super-class connect first, and return a promise which executes when the super-class promise completes.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
additional socket.io options |
- Source:
Returns:
Resolved when the connection is made to the server
- Type
- Promise
disconnect()
Disconnect from game server
- Source:
sendInput(input, inputOptions)
This function should be called by the client whenever a user input occurs. This function will emit the input event, forward the input to the client's game engine (with a delay if so configured) and will transmit the input to the server as well.
This function can be called by the extended client engine class, typically at the beginning of client-side step processing {@see GameEngine#client__preStep}.
Parameters:
Name | Type | Description |
---|---|---|
input |
String | string representing the input |
inputOptions |
Object | options for the input |
- Source:
start() → {Promise}
Start the client engine, setting up the game loop, rendering loop and renderer.
- Source:
Returns:
Resolves once the Renderer has been initialized, and the game is ready to connect
- Type
- Promise