API Documentation for: 0.11.8
Show:

platypus.components.Interactive Class

Module: platypus

Available since 0.9.0

This component accepts touches and clicks on the entity. It is typically automatically added by a render component that requires interactive functionality.

Methods

'camera-update'

(
  • camera.viewport
)

Defined in 'camera-update':93

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

Parameters:

'dispatch-event'

(
  • event
)

This event dispatches a PIXI.Event on this component's PIXI.Sprite. Useful for rerouting mouse/keyboard events.

Parameters:

  • event Object | PIXI.Event

    The event to dispatch.

'handle-render'

()

Defined in 'handle-render':103

Listens to this event to update whether the interactive element should be in button mode.

'input-off'

()

Defined in 'input-off':135

Removes the input event listeners on the sprite, disabling input.

'input-on'

()

Defined in 'input-on':124

Adds input event listeners to the sprite, enabling input.

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

buttonMode

Boolean

Defined in buttonMode:74

Determines whether hovering over the sprite should alter the cursor.

Default: false

container

PIXI.Container

Defined in container:22

Sets the container that represents the interactive area.

Default: null

hitArea

Object | String | Boolean

Defined in hitArea:31

Sets the hit area for interactive responses by describing the dimensions of a clickable rectangle:

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

A string can also be used to create more complex shapes via the PIXI graphics API like:

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

Defaults to the container if not specified or, if simply set to true, a rectangle using the entity's dimensions.

Default: null

hover

Boolean

Defined in hover:53

Sets whether the entity should respond to mouse hovering.

Default: false

relativeToSelf

String

Defined in relativeToSelf:62

Available since 0.9.3

Used when returning world coordinates. Typically coordinates are relative to the parent, but when this component is added to the layer level, coordinates must be relative to self.

Default: false

Events

'click'

deprecated

Defined in 'click':278

Deprecated: since v0.10.6 - superceded by the "pointertap" event.

This event is triggered on click.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'mousedown'

deprecated

Defined in 'mousedown':202

Deprecated: since v0.10.6 - superceded by the "pointerdown" event.

This event is triggered on mouse down.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'mousemove'

deprecated

Defined in 'mousemove':249

Deprecated: since v0.10.6 - superceded by the "pointermove" event.

This event is triggered on mouse move.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'mouseout'

deprecated

Defined in 'mouseout':306

Deprecated: since v0.10.6 - superceded by the "pointerout" event.

This event is triggered on mouse out.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'mouseover'

deprecated

Defined in 'mouseover':333

Deprecated: since v0.10.6 - superceded by the "pointerover" event.

This event is triggered on mouse over.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointerdown'

Defined in 'pointerdown':188

Available since v0.10.6

This event is triggered on pointer down.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointermove'

Defined in 'pointermove':223

Available since v0.10.6

This event is triggered on pointer move.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointerout'

Defined in 'pointerout':293

Available since v0.10.6

This event is triggered on pointer out.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointerover'

Defined in 'pointerover':320

Available since v0.10.6

This event is triggered on pointer over.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointertap'

Defined in 'pointertap':265

Available since v0.10.6

This event is triggered on pointer tap.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointerup'

Defined in 'pointerup':365

Available since v0.10.6

This event is triggered on pointer up.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pointerupoutside'

Defined in 'pointerupoutside':393

Available since v0.10.6

This event is triggered on pointer up outside.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pressmove'

Defined in 'pressmove':236

This event is triggered on press move (drag).

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.

'pressup'

Defined in 'pressup':352

This event is triggered on press up.

Event Payload:

  • event DOMEvent

    The original DOM pointer event.

  • pixiEvent PIXI.interaction.InteractionEvent

    The Pixi pointer event.

  • x Number

    The x coordinate in world units.

  • y Number

    The y coordinate in world units.

  • entity platypus.Entity

    The entity receiving this event.