Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SpriteSheet

Hierarchy

Index

Constructors

constructor

  • new SpriteSheet(gtpImage: Image, cellW: number, cellH: number, spacing?: number, spacingY?: number): SpriteSheet
  • Creates a sprite sheet.

    constructor

    Parameters

    • gtpImage: Image

      A GTP image that is the source for the sprite sheet.

    • cellW: number

      The width of a cell in the sprite sheet.

    • cellH: number

      The height of a cell in the sprite sheet.

    • Optional spacing: number
    • Optional spacingY: number

    Returns SpriteSheet

Properties

cellH

cellH: number

cellW

cellW: number

colCount

colCount: number

gtpImage

gtpImage: Image

rowCount

rowCount: number

size

size: number

spacingX

spacingX: number

spacingY

spacingY: number

Methods

drawByIndex

  • drawByIndex(ctx: CanvasRenderingContext2D, x: number, y: number, index: number): void
  • Draws a sprite in this sprite sheet by index (row*colCount + col).

    Parameters

    • ctx: CanvasRenderingContext2D

      The canvas' context.

    • x: number

      The x-coordinate at which to draw.

    • y: number

      The y-coordinate at which to draw.

    • index: number

      The index in the sprite sheet of the sprite to draw.

    Returns void

drawSprite

  • drawSprite(ctx: CanvasRenderingContext2D, x: number, y: number, row: number, col: number): void
  • Draws a sprite in this sprite sheet by row and column.

    Parameters

    • ctx: CanvasRenderingContext2D

      The canvas' context.

    • x: number

      The x-coordinate at which to draw.

    • y: number

      The y-coordinate at which to draw.

    • row: number

      The row in the sprite sheet of the sprite to draw.

    • col: number

      The column in the sprite sheet of the sprite to draw.

    Returns void

Generated using TypeDoc