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
Members
destroyed :Boolean
This read-only property shows whether this Messenger is destroyed.
Properties:
Name | Type | Description |
---|---|---|
destroyed |
- Overrides:
- Default Value:
- false
- Source:
Type:
-
Boolean
Methods
destroy()
This method destroys the game.
- Overrides:
- Source:
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.
getMessageIds() → {Array}
This method returns all the messages that this entity is concerned about.
- Overrides:
- Source:
Returns:
- Type:
-
Array
An array of strings listing all the messages for which this Messenger has handlers.
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. |
off(name, callback)
Remove the event listener
- Overrides:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The type of event; if no name is specifed remove all listeners. |
callback |
function
|
The listener function. |
on(name, callback)
Add an event listener. The parameters for the listener functions depend on the event.
- Overrides:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
String
|
The type of event. |
callback |
function
|
The callback function when event is triggered. |
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:
toString()
Returns a string describing the Messenger as "[Messenger object]".
- Overrides:
- Source:
Returns:
String
trigger(event, value, debug) → {number}
This method is used by both internal components and external entities to trigger messages. When triggered, Messenger checks through bound handlers to run as appropriate. This handles multiple event structures: "", [], and {}
- Overrides:
- Source:
Parameters:
Name | Type | Description |
---|---|---|
event |
String
|
Array
|
Object
|
This is the message(s) to process. This can be a string, an object containing an "event" property (and optionally a "message" property, overriding the value below), or an array of the same. |
value |
*
|
This is a message object or other value to pass along to event handler. |
debug |
boolean
|
This flags whether to output message contents and subscriber information to the console during game development. A "value" object parameter (above) will also set this flag if value.debug is set to true. |
Returns:
- Type:
-
number
The number of handlers for the triggered message.
triggerEvent(event, valueopt) → {number}
This method is used by both internal components and external entities to trigger messages on this entity. When triggered, entity checks through bound handlers to run as appropriate. This method is identical to Spring Roll's EventDispatcher.trigger, but uses alternative Array methods to alleviate excessive GC.
- Overrides:
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
event |
String
|
This is the message to process. |
|||||||||
value |
*
|
<optional> |
This is a message object or other value to pass along to event handler.
|
Returns:
- Type:
-
number
The number of handlers for the triggered message.
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.
|