API Documentation for: 0.11.8
Show:

platypus.Scene Class

Extends springroll.State
Defined in: platypus.Scene:1
Module: platypus

This class is instantiated by Game and contains one or more entities as layers. Each layer Entity handles a unique aspect of the scene. For example, one layer might contain the game world, while another layer contains the game interface. Generally there is only a single scene loaded at any given moment.

JSON Definition

{
                            "layers":[
                            // Required array listing the entities that should be loaded as scene layers. These can be actual entity JSON definitions as shown in Entity or references to entities by using the following specification.
                        
                                {
                                    "type": "entity-id",
                                    // This value maps to an entity definition with a matching "id" value as shown in Entity and will load that definition.
                        
                                    "properties": {"x": 400}
                                    // Optional. If properties are passed in this reference, they override the entity definition's properties of the same name.
                                }
                            ],
                        
                            "assets": []
                            // Optional list of assets this scene requires.
                        }

Constructor

platypus.Scene

(
  • Stage
  • [definition]
)
Scene

Defined in platypus.Scene:1

Parameters:

  • Stage PIXI.Container

    Object where the scene displays layers.

  • [definition] Object optional

    Base definition for the scene, including one or more layers with both properties and components as shown above under "JSON Definition Example".

    • [id] String optional

      This declares the id of the scene.

    • [layers] Array optional

      This lists the layers that comprise the scene.

    • [assets] Array optional

      This lists the assets that this scene requires.

Returns:

Scene:

Returns the new scene made up of the provided layers.

Methods

exit

()

Defined in exit:331

This method destroys all the layers in the scene.

exitStart

()

Defined in exitStart:241

Triggers 'scene-ended' on the layer.

getAssetList

(
  • definition
)
Array

Defined in getAssetList:351

Returns all of the assets required for the Scene. This method calls the corresponding method on all entities to determine the list of assets. It ignores assets that have already been preloaded.

Parameters:

  • definition Object

    The definition for the Scene.

Returns:

Array:

A list of the necessary assets to load.

getEntitiesByType

(
  • type
)
Array

This method will return all game entities that match the provided type.

Parameters:

  • type String

    The entity type to find.

Returns:

Array:

entities Returns the entities that match the specified entity type.

getEntityById

(
  • id
)
Entity

Defined in getEntityById:281

This method will return the first entity it finds with a matching id.

Parameters:

  • id String

    The entity id to find.

Returns:

Entity:

Returns the entity that matches the specified entity id.

getLateAssetList

() Array

Returns all of the dynamic assets required for the Scene.

Returns:

Array:

A list of the necessary assets to load.

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:

  • eventId String

    This is the message to process.

  • event

    This is a message object or other value to pass along to component functions.

Events

'scene-ended'

Defined in 'scene-ended':249

Available since 0.7.1

This event is triggered on the layers once the Scene is over.

Event Payload:

  • data Object

    A list of key-value pairs of data sent into this Scene from the previous Scene.

'scene-live'

Defined in 'scene-live':232

This event is triggered on the layers once the Scene is finished loading.

Event Payload:

  • data Object

    A list of key-value pairs of data sent into this Scene from the previous Scene.

'scene-loaded'

Defined in 'scene-loaded':163

This event is triggered on the layers once the Scene is finished loading.

Event Payload:

  • data Object

    A list of key-value pairs of data sent into this Scene from the previous Scene.

  • holds platypus.Data

    An object that handles any holds on before making the scene live.

    • count Number

      The number of holds to wait for before triggering "scene-live"

    • release Function

      The method to trigger to let the scene loader know that one hold has been released.