Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Sprite<T>

Mandatory interface for sprites

Type parameters

Hierarchy

  • Sprite

Implemented by

Index

Methods

collides

  • collides(s: Shape<any>): boolean
  • Checks if Sprite collides a specified Shape

    Parameters

    • s: Shape<any>

      Shape to check

    Returns boolean

    true only if provided Rectangle collides the Sprite

contains

  • contains(p: Point): boolean
  • contains(coordX: number, coordY: number): boolean
  • Checks if a point is within the bounds (inclusive) of a Sprite

    Parameters

    • p: Point

      Point to check

    Returns boolean

    true only if Point is inside current Sprite area

  • Checks if a point is within the bounds (inclusive) of a Sprite

    Parameters

    • coordX: number

      Abscissa

    • coordY: number

      Ordinate

    Returns boolean

    true only if Point is inside current Sprite area

getIndex

  • getIndex(): number

getShape

  • getShape(): T
  • Returns the shape used to define this sprite

    Returns T

    underlying shape

getX

  • getX(): number
  • Gets abscissa of sprite

    Returns number

    Upper-left corner abscissa of sprite

getY

  • getY(): number
  • Gets ordinate of sprite

    Returns number

    upper-left corner ordinate of sprite

move

  • move(moveX: number, moveY: number): any
  • move(vect: Vector): any
  • moves sprite to relative position

    Parameters

    • moveX: number

      Added to current abscissa

    • moveY: number

      Added to current ordinate

    Returns any

  • moves sprite to relative position

    Parameters

    • vect: Vector

      Added to current position

    Returns any

moveTo

  • moveTo(coordX: number, coordY: number): void
  • moveTo(point: Point): void
  • Moves sprite to absolute position

    Parameters

    • coordX: number

      New abscissa

    • coordY: number

      New ordinate

    Returns void

  • Moves sprite to absolute position

    Parameters

    • point: Point

      New position

    Returns void

render

  • render(context: CanvasRenderingContext2D): void
  • Renders the sprite. Called each frame for each sprite, in the index order

    Parameters

    • context: CanvasRenderingContext2D

      Rendering context

    Returns void

setIndex

  • setIndex(newIndex: number): void
  • Set new index value. Whenever this method is called, engine must be informed

    engine.forceHierarchyUpdate()
    

    Parameters

    • newIndex: number

      new index value.

    Returns void

Generated using TypeDoc