Events

@:dox(show)complete(success:Bool):Void

@:dox(show)update(asset:Asset):Void

@:dox(show)progress(loaded:Int, total:Int, success:Bool):Void

@:dox(show)assetFilesChange(newFiles:ReadOnlyMap<String, Float>, previousFiles:ReadOnlyMap<String, Float>):Void

Static variables

@:value([])staticinstances:ReadOnlyArray<Assets> = []

@:value([])staticall:Array<String> = []

@:value([])staticallDirs:Array<String> = []

@:value(new Map())staticallByName:Map<String, Array<String>> = new Map()

@:value(new Map())staticallDirsByName:Map<String, Array<String>> = new Map()

Static methods

staticaddAssetKind(kind:String, add:(assets:Assets, name:String, variant:String, options:AssetOptions) ‑> Void, extensions:Array<String>, dir:Bool, types:Array<String>):Void

staticinlinegetAssetsPath():String

staticrealAssetPath(path:String, ?runtimeAssets:RuntimeAssets):String

staticgetReloadCount(realAssetPath:String):Int

Constructor

new()

Variables

@:value(new Immediate())read onlyimmediate:Immediate = new Immediate()

@:value(null)runtimeAssets:RuntimeAssets = null

If set, will be provided to each added asset in this Assets instance.

@:value(null)defaultImageOptions:AssetOptions = null

@:value(SYNC)loadMethod:AssetsLoadMethod = SYNC

@:value(PARALLEL)scheduleMethod:AssetsScheduleMethod = PARALLEL

@:value(-1)delayBetweenXAssets:Int = -1

@:value(null)parent:Assets = null

If provided, when requesting an asset, it will also check if the parent Assets instance has it and return it if that's the case.

@:value(null)atlasPacker:TextureAtlasPacker = null

A shared texture atlas packer that can be used to merge smaller textures together. Also required when loading some kind of assets, like .ase/.aseprite files.

@:value(false)hotReload:Bool = false

Set to true to enable hot reload. Note: this won't do anything unless used in pair with watchDirectory(path)

Methods

flush():Void

Destroy assets that have their refCount at 0.

add(id:AssetId<Dynamic>, ?variant:String, ?options:Null<AssetOptions>):Void

addAll(?pathPattern:EReg):Void

Add all assets matching given path pattern (if provided)

Parameters:

null

pathPattern

addImage(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addFont(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addAtlas(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addText(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addBinary(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addSound(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addDatabase(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addFragments(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addShader(name:String, ?variant:String, ?options:Null<AssetOptions>):Void

addAsset(asset:Asset):Asset

Add the given asset. If a previous asset was replaced, return it.

asset(idOrName:Dynamic, ?kind:String, ?variant:String):Asset

hasAnythingToLoad():Bool

Returns true if there are assets that should be loaded

Returns:

Bool

@:value({ warnIfNothingToLoad : true })load(warnIfNothingToLoad:Bool = true, ?pos:Null<PosInfos>):Void

ensure(id:AssetId<Dynamic>, ?variant:String, ?options:Null<AssetOptions>, done:Asset ‑> Void):Void

Ensures and asset is loaded and return it on the callback. This will check if the requested asset is currently being loaded, already loaded or should be added and loaded. In all cases, it will try its best to deliver the requested asset or null if something went wrong.

ensureImage(name:Either<String, AssetId<String>>, ?variant:String, ?options:Null<AssetOptions>, done:ImageAsset ‑> Void):Void

ensureFont(name:Either<String, AssetId<String>>, ?variant:String, ?options:Null<AssetOptions>, done:FontAsset ‑> Void):Void

ensureAtlas(name:Either<String, AssetId<String>>, ?variant:String, ?options:Null<AssetOptions>, done:AtlasAsset ‑> Void):Void

ensureText(name:Either<String, AssetId<String>>, ?variant:String, ?options:Null<AssetOptions>, done:TextAsset ‑> Void):Void

ensureSound(name:Either<String, AssetId<String>>, ?variant:String, ?options:Null<AssetOptions>, done:SoundAsset ‑> Void):Void

ensureShader(name:Either<String, AssetId<String>>, ?variant:String, ?options:Null<AssetOptions>, done:ShaderAsset ‑> Void):Void

@:value({ hotReload : true })watchDirectory(?path:String, hotReload:Bool = true):WatchDirectory

Watch the given asset directory. Any change will fire assetFilesChange event. If hotReload is set to true (its default), related assets will be hot reloaded when their file changes on disk. Behavior may differ depending on the platfom. When using web target via electron, be sure to add ceramic_use_electron define.

Parameters:

path

The assets path to watch. You could use ceramic.macros.DefinesMacro.getDefine('assets_path') to watch default asset path in project. It's the path that will be used if none is provided

hotReload

true by default. Will enable hot reload of assets when related file changes on disk

Returns:

WatchDirectory instance used internally

Inherited Events

Defined by Entity

@:dox(show)dispose(entity:Entity):Void

@:dox(show)destroy(entity:Entity):Void

Inherited Variables

Defined by Entity

read onlyhasData:Bool

@:value(null)id:String = null

read onlydestroyed:Bool

read onlydisposed:Bool

@:value(null)read onlyautoruns:Array<Autorun> = null

@editablecomponents:ReadOnlyMap<String, Component>

Public components mapping. Contain components created separately with component() or macro-based components as well.

scriptContent:ScriptContent

Available with script plugin

script:Script

Available with script plugin

Inherited Methods

Defined by Entity

dispose():Void

Schedules destroy, at the end of the current frame.

unbindEvents():Void

Remove all events handlers from this entity.

autorun(run:() ‑> Void, ?afterRun:() ‑> Void):Autorun

Creates a new Autorun instance with the given callback associated with the current entity.

Parameters:

run

The run callback

Returns:

The autorun instance

tween(?easing:Easing, duration:Float, fromValue:Float, toValue:Float, update:(Float, Float) ‑> Void):Tween

component<C>(?name:String, ?component:Null<C>):C