import { Vec2D } from '../Math'; declare class Sprite { private static pathPrefix; private accumulator; private finished; private maxFrames; private onFrame; private onFinish; /** * Source image element */ readonly img: HTMLImageElement; /** * Local image coordinates of the animation frames */ readonly frames: Vec2D[]; /** * Size of an individual sprite animation frame */ readonly size: Vec2D; /** * Current frame index */ currentFrame: number; /** * An animated sprite from an image file. * * @param file Filepath to the target image * @param frameX Width of each frame * @param frameY Height of each frame * @param nframes Maximum number of frames * @param onLoad On-load callback function * @param onError On-error callback function * @return Sprite object */ private constructor(); /** * Set the path prefix for where to load image files */ static setPathPrefix(prefix: string): void; /** * Create a new sprite, returning a promise * * @param file Filepath to the target image * @param frameX Width of each frame * @param frameY Height of each frame * @param nframes Maximum number of frames * @param includePrefix Include the prefix in the filename * @return Promise to a Sprite object */ static create(file: string, frameX?: number, frameY?: number, nframes?: number, includePrefix?: boolean): Promise; /** * Set the callback for when the animation finishes * * @param callback Callback method */ setOnFinish(callback: () => void): void; /** * Set the callback for the start of an animation frame * The callback should take an index representing the current frame * * @param callback Callback method */ setOnFrame(callback: (frame: number) => void): void; /** * Animate the sprite and update its current frame. * Call it on every tick. * * @param dt Delta-time from previous tick * @param fps Animation rate * @param loop Does the animation loop? */ animate(dt: number, fps: number, loop?: boolean): void; /** * Restart the animation */ restart(): void; /** * Check if the sprite's animation has finished. * * If the sprite is looping, it will always return false * * @returns Sprite animation finished? */ isFinished(): boolean; } export { Sprite };