Class Spritesheet

Multiple sprites loaded from a single image

Hierarchy

  • Spritesheet

Constructors

  • Creates a new Spritesheet object

    Parameters

    • src: string

      Url of the image

    Returns Spritesheet

Properties

canvas: HTMLCanvasElement
ctx: CanvasRenderingContext2D
loaded: boolean = false
sprites: ImageDataList = {}
src: string

Methods

  • Saves multiple sprites of the same size automatically

    Parameters

    • w: number

      Width of the sprites

    • h: number

      Height of the sprites

    Returns boolean

    True if the sprites were saved successfully

  • Loads the image

    Returns Promise<boolean>

  • Saves the full image as a sprite called "full"

    Returns boolean

  • Saves a custom sprite

    Parameters

    • name: string

      Name of the sprite

    • x: number

      X position of the sprite

    • y: number

      Y position of the sprite

    • w: number

      Width of the sprite

    • h: number

      Height of the sprite

    Returns boolean

    True if the sprite was saved successfully

Generated using TypeDoc