import TextureOptions from "../textures/TextureOptions"; import TextureAtlas from "../textures/TextureAtlas"; import Texture from "../textures/Texture"; import BitmapFont from "../text/BitmapFont"; import EventDispatcher from "../events/EventDispatcher"; import ByteArray from "openfl/utils/ByteArray"; import SoundTransform from "openfl/media/SoundTransform"; import SoundChannel from "openfl/media/SoundChannel"; import Sound from "openfl/media/Sound"; import Context3DTextureFormat from "openfl/display3D/Context3DTextureFormat"; import Vector from "openfl/Vector"; declare namespace starling.utils { /** * Dispatched when all textures have been restored after a context loss. */ export class AssetManager extends EventDispatcher { /** * Create a new AssetManager. The 'scaleFactor' and 'useMipmaps' parameters define * * how enqueued bitmaps will be converted to textures. */ constructor(scaleFactor?: number, useMipmaps?: boolean); /** * Disposes all contained textures, XMLs and ByteArrays. * * * *
Beware that all references to the assets will remain intact, even though the assets * * are no longer valid. Call 'purge' if you want to remove all resources and reuse * * the AssetManager later.
* */ dispose(): void; /** * Returns a texture with a certain name. The method first looks through the directly * * added textures; if no texture with that name is found, it scans through all * * texture atlases. */ getTexture(name: string): Texture; /** * Returns all textures that start with a certain string, sorted alphabetically * * (especially useful for "MovieClip"). */ getTextures(prefix?: string, out?: Vectorout-vector, the names will be added to that vector.
*/
getTextureAtlasNames(prefix?: string, out?: Vectorout-vector, the names will be added to that vector.
*/
getSoundNames(prefix?: string, out?: Vectorout-vector, the names will be added to that vector.
*/
getXmlNames(prefix?: string, out?: Vectorout-vector, the names will be added to that vector.
*/
getObjectNames(prefix?: string, out?: Vectorout-vector, the names will be added to that vector.
*/
getByteArrayNames(prefix?: string, out?: Vectorout-vector, the names will be added to that vector.
*/
getBitmapFontNames(prefix?: string, out?: VectorNote that the font is not registered at the TextField class. * * This only happens when a bitmap font is loaded via the asset queue.
* */ addBitmapFont(name: string, font: BitmapFont): void; /** * Removes a certain texture, optionally disposing it. */ removeTexture(name: string, dispose?: boolean): void; /** * Removes a certain texture atlas, optionally disposing it. */ removeTextureAtlas(name: string, dispose?: boolean): void; /** * Removes a certain sound. */ removeSound(name: string): void; /** * Removes a certain Xml object, optionally disposing it. */ removeXml(name: string, dispose?: boolean): void; /** * Removes a certain object. */ removeObject(name: string): void; /** * Removes a certain byte array, optionally disposing its memory right away. */ removeByteArray(name: string, dispose?: boolean): void; /** * Removes a certain bitmap font, optionally disposing it. */ removeBitmapFont(name: string, dispose?: boolean): void; /** * Empties the queue and aborts any pending load operations. */ purgeQueue(): void; /** * Removes assets of all types (disposing them along the way), empties the queue and * * aborts any pending load operations. */ purge(): void; /** * Enqueues one or more raw assets; they will only be available after successfully * * executing the "loadQueue" method. This method accepts a variety of different objects: * * * *png, jpg, gif, atf, mp3, xml, fnt, json, binary.static embedded assets.Suitable object names are extracted automatically: A file named "image.png" will be * * accessible under the name "image". When enqueuing embedded assets via a class, * * the variable name of the embedded object will be used as its name. An exception * * are texture atlases: they will have the same name as the actual texture they are * * referencing.
* * * *XMLs that contain texture atlases or bitmap fonts are processed directly: fonts are * * registered at the TextField class, atlas textures can be acquired with the * * "getTexture()" method. All other XMLs are available via "getXml()".
* * * *If you pass in JSON data, it will be parsed into an object and will be available via * * "getObject()".
* */ enqueue(rawAssets: ArrayWhen you call this method, the manager will save a reference to "Starling.current"; * * all textures that are loaded will be accessible only from within this instance. Thus, * * if you are working with more than one Starling instance, be sure to call * * "makeCurrent()" on the appropriate instance before processing the queue.
* * * * @param onProgressfunction(ratio:Number):void;
*
*/
loadQueue(onProgress: (arg0: number) => void): void;
/**
* Returns the number of raw assets that have been enqueued, but not yet loaded.
*/
get numQueuedAssets(): number;
/**
* When activated, the class will trace information about added/enqueued assets.
* * @default true
*/
get verbose(): boolean;
set verbose(value: boolean)
/**
* Indicates if a queue is currently being loaded.
*/
get isLoading(): boolean;
/**
* For bitmap textures, this flag indicates if mip maps should be generated when they
* * are loaded; for ATF textures, it indicates if mip maps are valid and should be
* * used. @default false
*/
get useMipMaps(): boolean;
set useMipMaps(value: boolean)
/**
* Textures that are created from Bitmaps or ATF files will have the scale factor
* * assigned here. @default 1
*/
get scaleFactor(): number;
set scaleFactor(value: number)
/**
* Textures that are created from Bitmaps will be uploaded to the GPU with the
* * Context3DTextureFormat assigned to this property. @default "bgra"
*/
get textureFormat(): Context3DTextureFormat;
set textureFormat(value: Context3DTextureFormat)
/**
* Indicates if the underlying Stage3D textures should be created as the power-of-two based
* * Texture class instead of the more memory efficient RectangleTexture.
* * @default false
*/
get forcePotTextures(): boolean;
set forcePotTextures(value: boolean)
/**
* Specifies whether a check should be made for the existence of a URL policy file before
* * loading an object from a remote server. More information about this topic can be found
* * in the 'flash.system.LoaderContext' documentation. @default false
*/
get checkPolicyFile(): boolean;
set checkPolicyFile(value: boolean)
/**
* Indicates if atlas XML data should be stored for access via the 'getXml' method.
* * If true, you can access an XML under the same name as the atlas.
* * If false, XMLs will be disposed when the atlas was created. @default false.
*/
get keepAtlasXmls(): boolean;
set keepAtlasXmls(value: boolean)
/**
* Indicates if bitmap font XML data should be stored for access via the 'getXml' method.
* * If true, you can access an XML under the same name as the bitmap font.
* * If false, XMLs will be disposed when the font was created. @default false.
*/
get keepFontXmls(): boolean;
set keepFontXmls(value: boolean)
/**
* The maximum number of parallel connections that are spawned when loading the queue.
* * More connections can reduce loading times, but require more memory. @default 3.
*/
get numConnections(): number;
set numConnections(value: number)
/**
* Indicates if bitmap fonts should be registered with their "face" attribute from the
* * font XML file. Per default, they are registered with the name of the texture file.
* * @default false
*/
get registerBitmapFontsWithFontFace(): boolean;
set registerBitmapFontsWithFontFace(value: boolean)
get_registerBitmapFontsWithFontFace(): boolean;
set_registerBitmapFontsWithFontFace(value: boolean): boolean;
}
}
export default starling.utils.AssetManager;