DownloadTask
Extends: LoadTask
Downloads a URL to a local file. A copy cached by an earlier download (even in an earlier launch) is used without a request. Queue one with AssetLoader.download(); once it's done without an error, localPath is the file.
Properties
url(string) — The URL being downloadedlocalPath(string) — The local file, once donefromCache(boolean) — True if the file was already cached, so no request was madeelapsedMs(integer) — How long the download took, in milliseconds (0 for a cached file)slots(BGE.DownloadSlots) — Shared with the other downloads in the same loader, to limit how many run at oncetimer(BGE.GameTimer) — Times each attempt, for the timeout
Constructor
new DownloadTask(
url: string,
options?: BGE.DownloadOptions,
): DownloadTaskParameters
url(string)options(BGE.DownloadOptions, optional, default: "{}")
Instance Methods
step(budgetMs: integer): boolean
Parameters
budgetMs(integer)
Returns
boolean
getProgress(): float
Returns
float
createTransfer(): dynamic
Creates the roUrlTransfer for each attempt. Override to customise requests (headers etc).
Returns
dynamic— an roUrlTransfer
createPort(): dynamic
Creates the message port each attempt's events arrive on.
Returns
dynamic— an roMessagePort
isFinished(): boolean
Whether step() has returned true.
Returns
boolean
wasAborted(): boolean
Whether abort() was called before the download finished.
Returns
boolean
abort(): void
Returns
void