Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Sprite

A drawable object made from an image ressource. Can be rotated, flipped, scalled and translated around in the canvas.

Hierarchy

Index

Constructors

  • new Sprite(image: CanvasImageSource, sourceRect: Rect, destRect?: Rect): Sprite
  • Parameters

    • image: CanvasImageSource

      sprite image

    • sourceRect: Rect

      rectangle in the texture

    • Optional destRect: Rect

      rectangle in the canvas

    Returns Sprite

Properties

anchor: AnchorType
destRect: Rect
flipX: boolean = false
flipY: boolean = false
image: CanvasImageSource
rotation: number = 0
scale: number = 1
sourceRect: Rect

Accessors

  • Position of the sprite defined by anchor Do not set components of the position directly, it will not update it properly. Instead, assign to the property:

    example
    const p = sprite.pos
    p.x += 0.5;
    sprite.pos = p;

    Returns Vec2

  • Position of the sprite defined by anchor Do not set components of the position directly, it will not update it properly. Instead, assign to the property:

    example
    const p = sprite.pos
    p.x += 0.5;
    sprite.pos = p;

    Parameters

    Returns void

  • The rect bounding the sprite, taking scaling into account.

    Returns Rect

Methods

  • Draw the sprite on a canvas.

    Parameters

    Returns Sprite

Generated using TypeDoc