Collectable |

addAnimation

  • addAnimation(
        name: string,
        index: string[] | number[] | object[],
        animationspeed?: number,
    ): number

    Parameters

    • name: string
    • index: string[] | number[] | object[]
    • Optionalanimationspeed: number

    Returns number

    frame amount of frame added to the animation (delay between each frame).

angleTo

  • angleTo(target: any): number

    Returns number

    angle in radians

centerOn

  • Parameters

    • x: number
    • y: number

    Returns Collectable

    this rectangle

clone

  • Returns Rect

    new rectangle

contains

  • contains(x: number, y: number): boolean

    Parameters

    • x: number
    • y: number

    Returns boolean

    True if the polygon contain the point, otherwise false

  • Returns boolean

    True if the polygon contain the point, otherwise false

containsRectangle

  • containsRectangle(rectangle: Rect): boolean

    Parameters

    Returns boolean

    True if the rectangle contain the given rectangle, otherwise false

copy

distanceTo

  • distanceTo(target: any): number

draw

  • Returns void

equals

  • equals(rect: Rect): boolean

    Returns boolean

    true if equals

flicker

  • flicker(duration: number, callback?: Function): Sprite

    Parameters

    • duration: number
    • Optionalcallback: Function = undefined

    Returns Sprite

    Reference to this object for method chaining

flipX

  • Parameters

    • Optionalflip: boolean = true

    Returns Renderable

    Reference to this object for method chaining

flipY

  • Parameters

    • Optionalflip: boolean = true

    Returns Renderable

    Reference to this object for method chaining

getAbsolutePosition

  • getAbsolutePosition(): Vector2d

    Returns Vector2d

getBounds

  • Returns Bounds

    bounding box Rectangle object

getCurrentAnimationFrame

  • getCurrentAnimationFrame(): number

    Returns number

    current animation frame index

getIndices

  • Returns number[]

    an array of vertex indices for all triangles forming this polygon.

getOpacity

  • Returns number

    current opacity value between 0 and 1

isConvex

  • isConvex(): boolean | null

    Returns boolean | null

    true if the vertices are convex, false if not, null if not computable

isCurrentAnimation

  • isCurrentAnimation(name: string): boolean

    Returns boolean

isFinite

  • Returns boolean

    false if all coordinates are positive or negative Infinity or NaN; otherwise, true.

isFlickering

  • Returns boolean

lookAt

  • Returns Renderable

    Reference to this object for method chaining

onCollision

  • Returns boolean

    true if the object should respond to the collision (its position and velocity will be corrected)

onDestroyEvent

  • Returns void

overlaps

  • overlaps(rect: Rect): boolean

    Returns boolean

    true if overlaps

pause

  • Returns void

play

  • Returns void

postDraw

preDraw

  • Returns void

recalc

  • Returns Collectable

    Reference to this object for method chaining

resize

  • Parameters

    • w: number
    • h: number

    Returns Collectable

    this rectangle

reverseAnimation

  • reverseAnimation(name?: string): Sprite

    Parameters

    • Optionalname: string

    Returns Sprite

    Reference to this object for method chaining

rotate

  • Parameters

    • angle: number
    • Optionalv: any

    Returns Renderable

    Reference to this object for method chaining

scale

  • Parameters

    • x: number
    • Optionaly: number = x

    Returns Renderable

    Reference to this object for method chaining

scaleV

  • Returns Renderable

    Reference to this object for method chaining

setAnimationFrame

  • setAnimationFrame(index?: number): Sprite

    Parameters

    • Optionalindex: number = 0

    Returns Sprite

    Reference to this object for method chaining

setCurrentAnimation

  • setCurrentAnimation(
        name: string,
        resetAnim?: string | Function,
        preserve_dt?: boolean,
    ): Sprite

    Parameters

    • name: string
    • OptionalresetAnim: string | Function
    • Optionalpreserve_dt: boolean = false

    Returns Sprite

    Reference to this object for method chaining

setOpacity

  • setOpacity(alpha: number): void

    Returns void

setRegion

  • setRegion(region: object): Sprite

    Returns Sprite

    Reference to this object for method chaining

setShape

setSize

  • Parameters

    • width: number
    • height: number

    Returns Collectable

setVertices

shift

  • shift(x: number, y?: number): void

    Parameters

    • x: number
    • Optionaly: number

    Returns void

  • Returns void

to2d

  • Returns Collectable

    Reference to this object for method chaining

toIso

  • Returns Collectable

    Reference to this object for method chaining

toPolygon

  • Returns Polygon

    a new Polygon that represents this rectangle.

transform

  • Returns Renderable

    Reference to this object for method chaining

translate

  • translate(x: number, y?: number): Polygon

    Parameters

    • x: number
    • Optionaly: number

    Returns Polygon

    Reference to this object for method chaining

  • Returns Polygon

    Reference to this object for method chaining

union

Protectedupdate

  • update(dt: number): boolean

    Protected

    Returns boolean

    true if the Sprite is dirty

updateBounds

  • updateBounds(absolute?: boolean): Bounds

    Parameters

    • Optionalabsolute: boolean = true

    Returns Bounds

    this shape bounding box Rectangle object