Orientation

platypus.components. Orientation

new Orientation()

This component handles the orientation of an entity. It maintains an orientationMatrix property on the owner to describe the entity's orientation using an affine transformation matrix.

Several methods on this component accept either a 3x3 2D Array or a string to describe orientation changes. Accepted strings include:

  • "horizontal" - This flips the entity around the y-axis.
  • "vertical" - This flips the entity around the x-axis.
  • "diagonal" - This flips the entity around the x=y axis.
  • "diagonal-inverse" - This flips the entity around the x=-y axis.
  • "rotate-90" - This rotates the entity 90 degrees clockwise.
  • "rotate-180" - This rotates the entity 180 degrees clockwise (noticeable when tweening).
  • "rotate-270" - This rotates the entity 90 degrees counter-clockwise.

NOTE: This component absorbs specific properties already on the entity into orientation:

  • orientationMatrix: 3x3 2D array describing an affine transformation.
  • If the above is not provided, these properties are used to set initial orientation. This is useful when importing Tiled maps.
    • scaleX: absorb -1 if described
    • scaleY: absorb -1 if described
    • rotation: absorb 90 degree rotations
Source:
Fires:
Listens to Events:

Methods

tweenTransform(options)

This message causes the component to begin tweening the entity's orientation over a span of time into the new orientation.

Source:
Parameters:
Name Type Description
options Object

A list of key/value pairs describing the tween options.

Name Type Attributes Description
matrix Array

A transformation matrix: only required if transform is not provided

transform String

A transformation type: only required if matrix is not provided.

time number

The time over which the tween occurs. 0 makes it instantaneous.

anchor platypus.Vector <optional>

The anchor of the orientation change. If not provided, the owner's position is used.

offset platypus.Vector <optional>

If an anchor is supplied, this vector describes the entity's distance from the anchor. It defaults to the entity's current position relative to the anchor position.

angle number <optional>

Angle in radians to transform. This is only valid for rotations and is derived from the transform if not provided.

tween function <optional>

A function describing the transition. Performs a linear transition by default. See CreateJS Ease for other options.

beforeTick function <optional>

A function that should be processed before each tick as the tween occurs. This function should return true, otherwise the tween doesn't take a step.

afterTick function <optional>

A function that should be processed after each tick as the tween occurs.

onFinished function <optional>

A function that should be run once the transition is complete.