UNPKG

evidently-pixi

Version:

TypeScript powered set of modules to make it easier to make games in Pixi.js.

63 lines (62 loc) 2.91 kB
import { ObjectKeymap } from "../GenericInterfaces"; import { TextureStore, TilesetTextureConfig } from "./TextureStore"; import * as PIXI from "pixi.js"; interface AssetLoaderConfiguration { textureStore?: TextureStore; } /** * Upgrade to Pixi's resource loader capable of handling all types of assets commonly used in games and importing them for * easy use. */ export declare class AssetLoader { private _resources?; private _wasStarted; private readonly _pendingTextures; private readonly _pendingSheets; private readonly _pendingTilesets; private readonly _pendingPixiAutoFonts; textureStore: TextureStore; constructor(config?: AssetLoaderConfiguration); /** * Queues a texture to be loaded and registered in the [[TextureStore]]. * * @param {string} name Name by which the texture will be registered in [[TextureStore]]. * @param {string} imageUrl URL pointing to the image to load. * @throws {Error} Thrown when loading was already started. */ queueTexture(name: string, imageUrl: string): void; /** * Queues a spritesheet to be loaded. Every sprite in the sheet will be registered in the [[TextureStore]] with the name * of the sprite, optionally prefixed. * * @param {string} imageUrl URL pointing to the image to load for the spritesheet. * @param {object} sheetJson PIXI.SpriteSheet's format of data * @param {string=""} prefix Optional prefix which is added before every frame's name when loading it into * [[TextureStore]]. * @throws {Error} Thrown when loading was already started. */ queueSheet(imageUrl: string, sheetJson: ObjectKeymap, prefix?: string): void; /** * Queues a tileset to be registed in [[TextureStore]]. * * @param {string} name Name of the texture to use as a base for the tileset - it may be a separately loaded texture * or one of spritesheet's frames. * @param {TilesetTextureConfig} config Tileset configuration. * @throws {Error} Thrown when loading was already started. */ queueTileset(name: string, config: TilesetTextureConfig): void; queuePixiAutoFont(name: string, fontXmlUrl: string): void; /** * Loads the queued assets and registers them in the appropriate stores. * @param {PIXI.Loader} loader Loader instance to use. In most cases you just want to pass the static PIXI Loader. * @return {Promise<boolean>} A promise that resolves when all of the operations are finishes successfully. Value of the promise will * always be `true`. * @throws {Error} Thrown when loading was already started. */ load(loader: PIXI.Loader): Promise<boolean>; private loadTextures; private loadSpritesheets; private loadTilesets; private assertNotStarted; } export {};