API Documentation for: 0.11.8
Show:

platypus.components.RenderContainer Class

Module: platypus

Available since 0.11.0

This component is attached to entities that will appear in the game world. It creates a PIXI Container to contain all other display objects on the entity and keeps the container updates with the entity's location and other dynamic properties.

Methods

'cache'

()

Defined in 'cache':315

On receiving a "cache" event, this component triggers "cache-sprite" to cache its rendering into the background. This is an optimization for static images to reduce render calls.

'camera-update'

(
  • camera.viewport
)

Defined in 'camera-update':337

Listens for this event to determine whether this sprite is visible.

Parameters:

'handle-render'

(
  • renderData
)

Defined in 'handle-render':364

The render update message updates the sprite. If a sprite doesn't have a container, it's removed.

Parameters:

  • renderData Object

    Data from the render handler

    • container PIXI.Container

      The parent container.

'handle-render-load'

(
  • handlerData
)

A setup message used to add the sprite to the stage. On receiving this message, the component sets its parent container to the stage contained in the message if it doesn't already have one.

Parameters:

  • handlerData Object

    Data from the render handler

    • container PIXI.Container

      The parent container.

'hide-sprite'

()

Defined in 'hide-sprite':381

This event makes the sprite invisible.

'set-mask'

(
  • mask
)

Defined in 'set-mask':399

Defines the mask on the container/sprite. If no mask is specified, the mask is set to null.

Parameters:

  • mask Object

    The mask. This can specified the same way as the 'mask' parameter on the component.

'show-sprite'

()

Defined in 'show-sprite':390

This event makes the sprite visible.

addEventListener

(
  • event
  • callback
)
Function private
This method adds an event listener to the entity.

Parameters:

  • event String
    The event that this component should listen for.
  • callback Function
    The handler for the event.

Returns:

Function: handler A reference to the bound handler.

addMethod

(
  • name
  • func
)
private
This method adds a method to the entity.

Parameters:

  • name String
    The name of the method. For example, if name is "turnYellow", the method is accessible on the entity as entity.turnYellow().
  • func Function
    The function describing the method.

destroy

() private

Inherited from platypus.Component: destroy:54

This method cleans up listeners and methods that this component added to the entity. It should never be called by the component itself. Call this.owner.removeComponent(this) instead.

getAssetList

(
  • definition
  • properties
  • defaultProperties
)
Array
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.

Parameters:

  • definition Object
    The definition for the component.
  • properties Object
    The properties of the Entity.
  • defaultProperties Object
    The default properties of the Entity.

Returns:

Array: A list of the necessary assets to load.

getLateAssetList

(
  • data
)
Array
This method can be overwritten to provide the list of assets this component requires. This method is invoked when the list of game scenes is created to determine assets for each scene.

Parameters:

  • data Object
    Scene data that affects the list of assets.

Returns:

Array: A list of the necessary assets to load.

removeEventListener

(
  • event
  • callback
)
private
This method removes an event listener from the entity.

Parameters:

  • event String
    The event for which to remove a listener.
  • callback Function
    The listener to remove. If not supplied, all event listeners for the provided event are removed.

removeEventListeners

(
  • [listeners]
)
private
This method removes multiple event listeners from the entity.

Parameters:

  • [listeners] Array optional
    The list of listeners to remove. If not supplied, all event listeners are removed.

removeMethod

(
  • name
)
private
This method removes a method from the entity.

Parameters:

  • name String
    The name of the method to be removed.

toJSON

() Object

Inherited from platypus.Component: toJSON:45

Available since 0.11.0

Returns a JSON object describing the component.

Returns:

Object: Returns a JSON definition that can be used to recreate the component.

toString

() String
Returns a string describing the component.

Returns:

String: Returns the component type as a string of the form "[Component ComponentType]".

Properties

cache

Boolean

Defined in cache:135

Optional. Whether this sprite should be cached into an entity with a RenderTiles component (like "render-layer"). The RenderTiles component must have its "entityCache" property set to true. Warning! This is a one-direction setting and will remove this component from the entity once the current frame has been cached.

Default: false

dragMode

Boolean

Defined in dragMode:155

Available since 0.8.3

Prevents sprite from becoming invisible out of frame and losing mouse input connection.

Default: false

flip

Boolean

Defined in flip:117

Optional. Whether this object can be flipped over Y. To flip it over Y set the this.owner.rotation to be > 180.

Default: false

ignoreOpacity

Boolean

Defined in ignoreOpacity:144

Optional. Ignores the opacity of the owner.

Default: false

interactive

Boolean | Object

Defined in interactive:79

Available since 0.9.0

Defines whether the entity will respond to touch and click events. Setting this value will create an Interactive component on this entity with these properties. For example:

"interactive": { "hover": false, "hitArea": { "x": 10, "y": 10, "width": 40, "height": 40 } }

Default: false

mask

Object

Defined in mask:59

Optional. A mask definition that determines where the image should clip. A string can also be used to create more complex shapes via the PIXI graphics API like: "mask": "r(10,20,40,40).dc(30,10,12)". Defaults to no mask or, if simply set to true, a rectangle using the entity's dimensions.

"mask": { "x": 10, "y": 10, "width": 40, "height": 40 },

-OR-

"mask": "r(10,20,40,40).dc(30,10,12)"

Default: null

mirror

Boolean

Defined in mirror:108

Whether this object can be mirrored over X. To mirror it over X set the this.owner.rotation value to be > 90 and < 270.

Default: false

rotate

Boolean

Defined in rotate:99

Optional. Whether this object can be rotated. It's rotational angle is set by setting the this.owner.rotation value on the entity.

Default: false

rotation

Number

Defined in rotation:165

Optional. The rotation of the sprite in degrees. All sprites on the same entity are rotated the same amount unless they ignore the rotation value by setting 'rotate' to false.

Default: 0

scaleX

Number

Defined in scaleX:174

Optional. The X scaling factor for the image. Defaults to 1.

Default: 1

scaleY

Number

Defined in scaleY:183

Optional. The Y scaling factor for the image. Defaults to 1.

Default: 1

skewX

Number

Defined in skewX:192

Optional. The X skew factor of the sprite. Defaults to 0.

Default: 0

skewY

Number

Defined in skewY:201

Optional. The Y skew factor for the image. Defaults to 0.

Default: 0

tint

Number

Defined in tint:210

Optional. The tint applied to the sprite. Defaults to no tint.

Default: null

visible

Boolean

Defined in visible:126

Optional. Whether this object is visible or not. To change the visible value dynamically set this.owner.state.visible to true or false.

Default: false

x

Number

Defined in x:219

Optional. The x position of the entity. Defaults to 0.

Default: 0

y

Number

Defined in y:228

Optional. The y position of the entity. Defaults to 0.

Default: 0

z

Number

Defined in z:237

Optional. The z position of the entity. Defaults to 0.

Default: 0

Events

'cache-sprite'

Defined in 'cache-sprite':325

On receiving a "cache" event, this component triggers "cache-sprite" to cache its rendering into the background. This is an optimization for static images to reduce render calls.

Event Payload:

'input-on'

Defined in 'input-on':421

This event is triggered once the RenderSprite is ready to handle interactivity.