API Documentation for: 0.11.8
Show:

platypus.components.LogicPortable Class

This component allows this entity to be carried by other entities with which it collides. Entities that should carry this entity need to have a [[Logic-Carrier]] component attached.

Methods

'force-release'

()

Defined in 'force-release':91

Available since 0.11.2

On receiving this message, this component immediately triggers 'release-me' on its owner's carrier.

'handle-logic'

()

Defined in 'handle-logic':33

On receiving this message, this component triggers 'carry-me' or 'release-me' if its connection to a carrying entity has changed.

'hit-solid'

(
  • collisionInfo.entity
  • collisionInfo.x
  • collisionInfo.y
)

Defined in 'hit-solid':71

On receiving this message, this component determines whether it is hitting its carrier or another entity. If it is hitting a new carrier, it will broadcast 'carry-me' on the next game step.

Parameters:

  • collisionInfo.entity platypus.Entity

    The entity with which the collision occurred.

  • collisionInfo.x Number

    -1, 0, or 1 indicating on which side of this entity the collision occurred: left, neither, or right respectively.

  • collisionInfo.y Number

    -1, 0, or 1 indicating on which side of this entity the collision occurred: top, neither, or bottom respectively.

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

dragZ

Number

Defined in dragZ:39

Available since 0.8.3

Sets the z-order of the item while being dragged.

Default: 10000

portableDirections

Object

This is an object specifying the directions that this portable entity can be carried on. Default is {down:true}, but "up", "down", "left", and/or "right" can be specified as object properties set to true.

Default: {"down": true}

stickyClick

Boolean

Defined in stickyClick:49

Available since 0.8.3

Sets whether a click-move should start the dragging behavior in addition to click-drag. This value is ignored for mobile devices.

Default: false

Events

'carry-me'

Defined in 'carry-me':47

This message is triggered on a potential carrying peer, notifying the peer that this entity is portable.

Event Payload:

'release-me'

Defined in 'release-me':59

This message is triggered on the current carrier, notifying them to release this entity.

Event Payload: