Skip to main content

GraphicsComponent

Component to manage drawings, using with the position component

Hierarchy

Index

Constructors

constructor

Properties

publiccopyGraphics

copyGraphics: boolean = false

If set to true graphics added to the component will be copied. This can effect performance, but is useful if you don't want changes to a graphic to effect all the places it is used.

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

publicflipHorizontal

flipHorizontal: boolean = false

Flip all graphics horizontally along the y-axis

publicflipVertical

flipVertical: boolean = false

Flip all graphics vertically along the x-axis

publicmaterial

material: Material = null

publicoptionalonPostDraw

onPostDraw?: (ctx: ExcaliburGraphicsContext, elapsedMilliseconds: number) => void

Draws after the entity transform has been applied, and after graphics component graphics has been drawn


Type declaration

    • Draws after the entity transform has been applied, and after graphics component graphics has been drawn


      Parameters

      Returns void

publicoptionalonPostTransformDraw

onPostTransformDraw?: (ctx: ExcaliburGraphicsContext, elapsedMilliseconds: number) => void

Draws after the entity transform has been applied, and after all graphics component drawing


Type declaration

publicoptionalonPreDraw

onPreDraw?: (ctx: ExcaliburGraphicsContext, elapsedMilliseconds: number) => void

Draws after the entity transform has been applied, but before graphics component graphics have been drawn


Type declaration

    • Draws after the entity transform has been applied, but before graphics component graphics have been drawn


      Parameters

      Returns void

publicoptionalonPreTransformDraw

onPreTransformDraw?: (ctx: ExcaliburGraphicsContext, elapsedMilliseconds: number) => void

Draws before the entity transform has been applied before any any graphics component drawing


Type declaration

publicopacity

opacity: number = 1

Sets or gets wither all drawings should have an opacity applied

optionalowner

owner?: Entity<any> = undefined

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

publicvisible

visible: boolean = true

Sets or gets wether any drawing should be visible in this component

Accessors

publicanchor

  • Anchor to apply to graphics by default


    Returns Vector

  • Parameters

    Returns void

publicbounds

  • Get world bounds of graphics component


    Returns BoundingBox

publiccurrent

  • Returns the currently displayed graphic


    Returns Graphic

publiccurrentOptions

publicgraphics

  • get graphics(): {}
  • Returns all graphics associated with this component


    Returns {}

publiclocalBounds

publicoffset

  • Offset to apply to graphics by default


    Returns Vector

  • Parameters

    Returns void

publicoptions

  • get options(): {}
  • Returns all graphics options associated with this component


    Returns {}

Methods

publicadd

  • Adds a named graphic to this component, if the name is "default" or not specified, it will be shown by default without needing to call


    Parameters

    Returns Graphic

publicclone

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


    Returns GraphicsComponent

publicgetGraphic

  • Parameters

    • name: string

    Returns Graphic

publicgetNames

  • getNames(): string[]
  • Get registered graphics names


    Returns string[]

publicgetOptions

publichide

  • hide(): void
  • Hide currently shown graphic


    Returns void

optionalonAdd

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


    Parameters

    Returns void

optionalonRemove

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


    Parameters

    Returns void

publicrecalculateBounds

  • recalculateBounds(): void
  • Returns void

publicremove

  • remove(name: string): void
  • Removes a registered graphic, if the removed graphic is the current it will switch to the default


    Parameters

    • name: string

    Returns void

publicshow

  • Shows a graphic, will be removed

    @deprecated

    will be removed in v0.30.0, use graphics.use(...)


    Type parameters

    Parameters

    Returns T

publicuse

  • Use a graphic only, will set the default graphic. Returns the new Graphic

    Optionally override the stored options


    Type parameters

    Parameters

    Returns T