Skip to main content

TransformComponent

Components are containers for state in Excalibur, the are meant to convey capabilities that an Entity possesses

Implementations of Component must have a zero-arg constructor to support dependencies

class MyComponent extends ex.Component {
  // zero arg support required if you want to use component dependencies
  constructor(public optionalPos?: ex.Vector) {}
}

Hierarchy

Index

Constructors

constructor

Properties

optionalreadonlydependencies

dependencies?: ComponentCtor<Component>[]

Optionally list any component types this component depends on If the owner entity does not have these components, new components will be added to the entity

Only components with zero-arg constructors are supported as automatic component dependencies

optionalowner

owner?: Entity<any> = undefined

Current owning Entity, if any, of this component. Null if not added to any Entity

publiczIndexChanged$

zIndexChanged$: Observable<number> = ...

Observable that emits when the z index changes on this component

Accessors

publiccoordPlane

globalPos

globalRotation

  • get globalRotation(): number
  • set globalRotation(rotation: number): void
  • Returns number

  • Parameters

    • rotation: number

    Returns void

globalScale

publicglobalZ

  • get globalZ(): number
  • set globalZ(z: number): void
  • Returns number

  • Parameters

    • z: number

    Returns void

pos

rotation

  • get rotation(): number
  • set rotation(rotation: number): void
  • Returns number

  • Parameters

    • rotation: number

    Returns void

scale

publicz

  • get z(): number
  • set z(val: number): void
  • The z-index ordering of the entity, a higher values are drawn on top of lower values. For example z=99 would be drawn on top of z=0.


    Returns number

  • Parameters

    • val: number

    Returns void

Methods

apply

applyInverse

clone

  • Clones any properties on this component, if that property value has a clone() method it will be called


    Returns TransformComponent

publicget

onAdd

  • onAdd(owner: Entity<any>): void
  • Optional callback called when a component is added to an entity


    Parameters

    Returns void

onRemove

  • onRemove(_previousOwner: Entity<any>): void
  • Optional callback called when a component is removed from an entity


    Parameters

    Returns void