Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ImageSprite

Sprite implementation that manage a simple image

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected index

index: number

Order for sprite rendering

Protected shape

shape: Circle | Rectangle

Protected spriteImage

spriteImage: HTMLImageElement

Managed image

Methods

addRotation

  • addRotation(degrees: number): void
  • Adds angle to current rotation

    Parameters

    • degrees: number

      Rotation angle in degrees (delta)

    Returns 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
  • Gets referenced image

    Returns HTMLImageElement

    The Image object managed by this sprite

getIndex

  • getIndex(): number

getRotation

  • getRotation(): number
  • Get current rotation angle

    Returns number

    rotation angle in degrees

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

render

  • render(context: CanvasRenderingContext2D): 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

setRotation

  • setRotation(degrees: number): void
  • Set new rotation angle

    Parameters

    • degrees: number

      Rotation angle in degrees (from original image)

    Returns void

Generated using TypeDoc