Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TextSprite

Simple sprite wrapper for Text

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private align

align: TextAlign

Private font

font: Font

Protected index

index: number

Order for sprite rendering

Private offCanvas

offCanvas: HTMLCanvasElement

Canvas used for off-screen rendering (double buffering)

Private offCtx

offCtx: CanvasRenderingContext2D

off-screen Canvas rendering context

Protected shape

shape: Rectangle

Private text

text: string

Text content

Methods

addRotation

  • addRotation(degrees: number): void
  • Adds angle to current rotation

    Parameters

    • degrees: number

      Rotation angle in degrees (delta)

    Returns void

collides

  • Checks if Sprite collides a specified Rectangle

    Parameters

    Returns boolean

    true only if provided Rectangle collides the Sprite

contains

  • contains(p: Point): boolean
  • contains(coordX: number, coordY: number): boolean

getIndex

  • getIndex(): number

getRotation

  • getRotation(): number
  • Get current rotation angle

    Returns number

    rotation angle in degrees

getShape

getText

  • getText(): string

getX

  • getX(): number

getY

  • getY(): number

move

  • move(moveX: number, moveY: number): void
  • move(vect: Vector): void

moveTo

  • moveTo(coordX: number, coordY: number): void
  • moveTo(point: Point): any

render

  • render(context: CanvasRenderingContext2D): void

setIndex

  • setIndex(newIndex: number): void

setRotation

  • setRotation(degrees: number): void
  • Set new rotation angle

    Parameters

    • degrees: number

      Rotation angle in degrees (from original image)

    Returns void

setText

  • setText(text: string): void
  • Defines new content for text sprite

    Parameters

    • text: string

      Text to display

    Returns void

Generated using TypeDoc