Constructor
new Game(definition, options, onFinishedLoadingopt) → {platypus.Game}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
definition |
Object
|
Collection of configuration settings, typically from config.json. |
|
options |
Object
|
Options describing the display options, Springroll features, etc. |
|
onFinishedLoading |
function
|
<optional> |
An optional function to run once the game has begun. |
Extends
Methods
getEntitiesByType(type) → {Array}
This method will return all game entities that match the provided type.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
String
|
The entity type to find. |
Returns:
- Type:
-
Array
entities Returns the entities that match the specified entity type.
getEntityById(id) → {Entity}
This method will return the first entity it finds with a matching id.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string
|
The entity id to find. |
Returns:
- Type:
-
Entity
Returns the entity that matches the specified entity id.
load(layerId, data, isScene, progressIdOrFunction)
Loads one or more layers.
If one layer is specified, it will complete loading if no other layers are already loading. If other layers are presently loading, it will complete as soon as other layers are complete.
If an array of layers is specified, all layers must finish loading before any receive a completion event.
Parameters:
| Name | Type | Description |
|---|---|---|
layerId |
Array
|
String
|
The layer(s) to load. |
data |
Object
|
A list of key/value pairs describing options or settings for the loading scene. |
isScene |
Boolean
|
Whether the layers from a previous scene should be replaced by these layers. |
progressIdOrFunction |
String
|
function
|
Whether to report progress. A string sets the id of progress events whereas a function is called directly with progress. |
Fires:
loadScene(layersOrId, data, progressIdOrFunction)
Loads a scene.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
layersOrId |
Array
|
Object
|
String
|
The list of layers, an object with a |
|
data |
Object
|
A list of key/value pairs describing options or settings for the loading scene. |
|
progressIdOrFunction |
String
|
function
|
scene |
Whether to report progress. A string sets the id of progress events whereas a function is called directly with progress. |
tick(ticker, tickMessage, deltaTime)
This method causes the game to tick once.
Parameters:
| Name | Type | Description |
|---|---|---|
ticker |
PIXI.Ticker
|
The ticker being used to set the game tick. |
tickMessage |
Object
|
Event tracking tick data. |
deltaTime |
number
|
The time elapsed since the last tick. |
Fires:
triggerOnChildren(eventId, event)
This method is used by external objects to trigger messages on the layers as well as internal entities broadcasting messages across the scope of the scene.
Parameters:
| Name | Type | Description |
|---|---|---|
eventId |
String
|
This is the message to process. |
event |
*
|
This is a message object or other value to pass along to component functions. |
unload(layer)
Unloads a layer.
Parameters:
| Name | Type | Description |
|---|---|---|
layer |
String
|
Object
|
The layer to unload. |
Events
tick
This event is triggered on the game as well as each layer currently loaded.
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
tickMessage |
Object
|
Event tracking tick data. This object is re-used for subsequent ticks.
|