Interface

SpriteComp

:

The sprite component.

group Component Types

draw

: Comp["draw"]

sprite

: string

Name of the sprite.

width

: number

Width for sprite.

height

: number

Height for sprite.

frame

: number

Current frame in the entire spritesheet.

animFrame

: number

Current frame in relative to the animation that is currently playing.

quad

: Quad

The rectangular area of the texture to render.

play

(anim: string, options?: SpriteAnimPlayOpt): void

Play a piece of anim.

stop

(): void

Stop current anim.

numFrames

(): number

Get total number of frames.

getCurAnim

(): SpriteCurAnim | null

Get the current animation data.

since v3001.0

curAnim

(): string | undefined

Get current anim name.

deprecated Use `getCurAnim().name` instead.

hasAnim

(name: string): boolean

Check if object's sprite has an animation.

getAnim

(name: string): SpriteAnim | null

Get an animation.

animSpeed

: number

Speed multiplier for all animations (for the actual fps for an anim use .play("anim", { speed: 10 })).

flipX

: boolean

Flip texture horizontally.

flipY

: boolean

Flip texture vertically.

onAnimStart

(action: (anim: string) => void): KEventController

Register an event that runs when an animation is played.

onAnimEnd

(action: (anim: string) => void): KEventController

Register an event that runs when an animation is ended.

renderArea

(): Rect

since v3000.0

kaplay logo

Layer

Miscalenous