Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SpriteTextureComponent

Class SpriteTextureComponent extends TextureComponent and override main method drawComponent. We need to keep tiles system working! Objective: Store and manipulate with image texture data. Render element Tile flip

void ctx.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight); JavaScript syntax: context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height); Parameter Values Parameter Description Play it img Specifies the image, canvas, or video element to use sx Optional. The x coordinate where to start clipping sy Optional. The y coordinate where to start clipping swidth Optional. The width of the clipped image sheight Optional. The height of the clipped image x The x coordinate where to place the image on the canvas y The y coordinate where to place the image on the canvas width Optional. The width of the image to use (stretch or reduce the image) height Optional. The height of the image to use (stretch or reduce the image)

Hierarchy

Implements

Index

Constructors

constructor

Properties

assets

assets: Resources = new Resources()

Protected horizontalFlip

horizontalFlip: boolean = false

Protected horizontalTiles

horizontalTiles: number = 1

keepAspectRatio

keepAspectRatio: boolean = true

Protected seqFrameX

seqFrameX: Counter

Protected seqFrameY

seqFrameY: Counter

Protected shema

shema: object

Type declaration

  • byX: number
  • byY: number

Protected verticalFlip

verticalFlip: boolean = false

Protected verticalTiles

verticalTiles: number = 1

Methods

drawComponent

  • drawComponent(c: CanvasRenderingContext2D, part: any): void

Protected flipImage

  • flipImage(image: any, ctx: any, sx: any, sy: any, sw: any, sh: any, flipH: any, flipV: any): void

Private nextColumn

  • nextColumn(): void

Private nextRow

  • nextRow(): void

setHorizontalFlip

  • setHorizontalFlip(newStatus: boolean): void

setHorizontalTiles

  • setHorizontalTiles(newHorinzontalTiles: number): this

setNewShema

  • setNewShema(shema: any): void

setNewShemaByX

  • setNewShemaByX(byX: number): void
  • It is not just set up xhema.byX, we need to reconstruct sequencer this.seqFrameX - his job is to to count frames by horisontal.

    Parameters

    • byX: number

      It is the number for sprite by horisontal devine img.width / x operation.

    Returns void

setNewShemaByY

  • setNewShemaByY(byY: number): void

setVerticalFlip

  • setVerticalFlip(newStatus: boolean): void

setVerticalTiles

  • setVerticalTiles(newVerticalTiles: number): this

Generated using TypeDoc