Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • SpriteSheet

Index

Constructors

constructor

  • new SpriteSheet(gridWidth: number, gridHeight: number, canvasWidth: number, canvasHeight: number, colors: string[]): SpriteSheet
  • Parameters

    • gridWidth: number

      The width of the grid, in tiles

    • gridHeight: number

      The height of the grid, in tiles

    • canvasWidth: number

      The width of the canvas, in pixels

    • canvasHeight: number

      The height of the canvas, in pixels

    • colors: string[]

    Returns SpriteSheet

Properties

Private spriteSheet

spriteSheet: HTMLCanvasElement

Private tileHeight

tileHeight: number

Private tileWidth

tileWidth: number

Methods

drawSprite

  • drawSprite(spriteId: number, colorIndex: number, context: CanvasRenderingContext2D, x: number, y: number): void
  • Draw a sprite to a canvas

    Parameters

    • spriteId: number

      The id of the sprite to draw

    • colorIndex: number
    • context: CanvasRenderingContext2D

      The canvas context to draw to

    • x: number

      The x position on the canvas to draw the sprite to

    • y: number

      The y position on the canvas to draw the sprite to

    Returns void

Generated using TypeDoc