Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TiledSprite

Extension of the ImageSprite to manage multi-frames (tiled) images

Hierarchy

Implements

Index

Constructors

constructor

  • new TiledSprite(image: HTMLImageElement | HTMLCanvasElement, frameCount: number, directions: Array<Direction>, frame: Rectangle, index?: number): TiledSprite
  • Parameters

    • image: HTMLImageElement | HTMLCanvasElement

      Tiled image. All frames must have the same size

    • frameCount: number

      Number of frames for each direction

    • directions: Array<Direction>

      The list of available directions, vertically aligned from top to bottom

    • frame: Rectangle

      A rectangle representing both the position of the Sprite and the dimension of a frame

    • Default value index: number = 1

      Order for sprite rendering

    Returns TiledSprite

Properties

Private currentFrame

currentFrame: number = 0

Current frame index

Protected directions

directions: Array<Direction>

The list of available directions, vertically aligned from top to bottom

Protected frameCount

frameCount: number

Number of frames for each direction

Protected index

index: number

Order for sprite rendering

Private indexDirection

indexDirection: number = 0

Direction

Protected shape

shape: Circle | Rectangle

Protected spriteImage

spriteImage: HTMLImageElement

Managed image

Methods

addRotation

  • addRotation(degrees: number): 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

getImage

  • getImage(): HTMLImageElement

getIndex

  • getIndex(): number

getRotation

  • getRotation(): number

getShape

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

nextFrame

  • nextFrame(): void

render

  • render(context: CanvasRenderingContext2D): void

setDirection

  • Searches for nearest available direction

    Parameters

    Returns void

setImage

  • setImage(newImage: HTMLImageElement | HTMLCanvasElement): void
  • Change referenced image. May be an image or a canvas. Internally converted to an image : Canvas may be modified and reused without inteference with current object.

    Parameters

    • newImage: HTMLImageElement | HTMLCanvasElement

      Reference to managed image

    Returns void

setIndex

  • setIndex(newIndex: number): void

setOrientation

  • setOrientation(orientationDegree: number): void
  • Defines new orientation for sprite

    Parameters

    • orientationDegree: number

      New orientation in degrees

    Returns void

setRotation

  • setRotation(degrees: number): void

Generated using TypeDoc