LoadTask
One unit of work for a BGE.AssetLoader: loading an asset, parsing part of a model, building part of a level. The loader calls step() repeatedly (several times a frame if it's fast, once a frame if it's slow) until it returns true.
Extend this class for your own work, or use AssetLoader.addStep() for a plain function.
Properties
name(string) — Shown in log messagesweight(float) — This task's share of the loader's overall progress, relative to the other taskserror(dynamic) — Set to a message string if the task failed. A failed task counts as done.done(boolean) — Set by the loader once step() has returned truedependsOn(Array.<LoadTask>) — Tasks that must finish before this one starts - see after()waitingForNextFrame(boolean) — Set true in step() when there's nothing more to do until next frame (e.g. waiting on aprogressHighWater(float) — Highest progress reported so far, kept by the loader so the bar never goes backwardsqueuedIn(string) — Id of the AssetLoader this task was queued in, set by the loaderqueueNumber(integer) — This task's number in that loader, set by the loader
Constructor
new LoadTask(): LoadTaskInstance Methods
step(budgetMs: integer): boolean
Does some of this task's work.
Parameters
budgetMs(integer) — roughly how many milliseconds this call may take
Returns
boolean— true once the task is finished (or has failed - seterror)
getProgress(): float
How far through its work this task is.
Returns
float— 0 to 1
abort(): void
Called by the loader if step() throws, to release anything the task holds.
Returns
void
after(other: BGE.LoadTask): object
Makes this task wait until another task has finished. If the other task fails, this one fails too without running.
Parameters
other(BGE.LoadTask)
Returns
object— this task, so calls can be chained