API Documentation for: 0.11.8
Show:

platypus.Messenger Class

Extends springroll.EventDispatcher
Defined in: platypus.Messenger:1
Module: platypus

The Messenger object facilitates communication between components and other game objects. Messenger is currently used by Entity and EntityContainer.

Methods

destroy

()

Defined in destroy:183

Available since 0.7.1

This method relinguishes Messenger properties

getMessageIds

() Array

Defined in getMessageIds:173

This method returns all the messages that this entity is concerned about.

Returns:

Array:

An array of strings listing all the messages for which this Messenger has handlers.

toString

()

Defined in toString:22

Returns a string describing the Messenger as "[Messenger object]".

Returns:

String

trigger

(
  • event
  • value
  • debug
)
Number

Defined in trigger:32

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 {}

Parameters:

  • 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:

Number:

The number of handlers for the triggered message.

triggerEvent

(
  • event
  • [value]
)
Number

Defined in triggerEvent:83

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.

Parameters:

  • event String

    This is the message to process.

  • [value] optional

    This is a message object or other value to pass along to event handler.

    • [debug] Boolean optional

      This flags whether to output message contents and subscriber information to the console during game development.

Returns:

Number:

The number of handlers for the triggered message.