FileLoadTask

Extends: LoadTask

Base for the built-in loads. Given a URL, the AssetLoader attaches a download; this task runs it first, then loads the downloaded file. Subclasses override loadFile() (and getFileProgress() if loading takes more than one step) rather than step().

Properties

  • path (string) — The file to load - the download's local file once downloaded
  • source (string) — The path or URL this task was given, for messages
  • download (BGE.DownloadTask) — Downloads path first when it's a URL (invalid for a local file)
  • downloadShare (float) — Share of this task's progress that the download counts for

Constructor

new FileLoadTask(path: string): FileLoadTask

Parameters

  • path (string)

Instance Methods

step(budgetMs: integer): boolean

Parameters

  • budgetMs (integer)

Returns

  • boolean

isDownloadedFileBad(): boolean

Whether a downloaded file that failed to load is broken, so it's deleted rather than kept in the cache. A load can fail with a good file, e.g. when texture memory runs out, so override this to check the file itself. The default says it's broken.

Returns

  • boolean

abort(): void

Returns

  • void

getProgress(): float

Returns

  • float

loadFile(budgetMs: integer): boolean

Loads the local file at path. Called repeatedly until it returns true.

Parameters

  • budgetMs (integer)

Returns

  • boolean — true when finished (set error on failure)

getFileProgress(): float

How far loadFile() has got, 0 to 1.

Returns

  • float