API Documentation for: 0.11.8
Show:

platypus.components.LogicDirectionalMovement Class

This component changes the Motion of an entity according to its current speed and heading. It accepts directional messages that can stand alone, or come from a mapped controller, in which case it checks the pressed value of the message before changing its course.

Methods

'accelerate'

(
  • velocity
)

Defined in 'accelerate':397

Changes the velocity of the Entity when in motion.

Parameters:

'component-added'

()

This method checks to make sure there is a Mover component attached and sets up initial heading.

'face'

(
  • direction
)

Defined in 'face':366

Set the direction the entity should face while stopped.

Parameters:

  • direction String

    A value such as "north" or "left" to point the entity in a particular direction.

'go-down'

(
  • [message.pressed]
)

Defined in 'go-down':219

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-down-left'

(
  • [message.pressed]
)

Defined in 'go-down-left':235

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-down-right'

(
  • [message.pressed]
)

Defined in 'go-down-right':331

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-east'

(
  • [message.pressed]
)

Defined in 'go-east':323

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-left'

(
  • [message.pressed]
)

Defined in 'go-left':251

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-north'

(
  • [message.pressed]
)

Defined in 'go-north':291

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-northeast'

(
  • [message.pressed]
)

Defined in 'go-northeast':307

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-northwest'

(
  • [message.pressed]
)

Defined in 'go-northwest':275

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-right'

(
  • [message.pressed]
)

Defined in 'go-right':315

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-south'

(
  • [message.pressed]
)

Defined in 'go-south':227

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-southeast'

(
  • [message.pressed]
)

Defined in 'go-southeast':339

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-southwest'

(
  • [message.pressed]
)

Defined in 'go-southwest':243

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-up'

(
  • [message.pressed]
)

Defined in 'go-up':283

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-up-left'

(
  • [message.pressed]
)

Defined in 'go-up-left':267

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-up-right'

(
  • [message.pressed]
)

Defined in 'go-up-right':299

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'go-west'

(
  • [message.pressed]
)

Defined in 'go-west':259

On receiving this message, this component updates its heading accordingly.

Parameters:

  • [message.pressed] Boolean optional

    If message is included, the component checks the value of pressed: true causes movement in the triggered direction, false turns off movement in that direction. Note that if no message is included, the only way to stop movement in a particular direction is to trigger stop on the entity before progressing in a new heading. This allows triggering up and left in sequence to cause up-left movement on the entity.

'handle-logic'

()

Defined in 'handle-logic':122

On receiving this message, the component updates its direction of motion according to its current state.

'stop'

(
  • message.pressed
)

Defined in 'stop':347

Stops motion in all directions until movement messages are again received.

Parameters:

  • message.pressed Object

    (boolean) - Optional. If message is included, the component checks the value of pressed: a value of false will not stop the entity.

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

axis

String

Defined in axis:44

Defines the axis around which the entity should be transformed. Defaults to "y" for platforming behavior. Use "z" for top-down behavior.

Default: "y"

speed

Number

Defined in speed:53

Defines the distance in world units that the entity should be moved per millisecond.

Default: 0.3