Loader#binary()

binary(key, url, callback, callbackContext) → {Phaser.Loader}

Adds a binary file to the current load queue.

The file is not loaded immediately after calling this method. The file is added to the queue ready to be loaded when the loader starts.

The key must be a unique String. It is used to add the file to the Phaser.Cache upon successful load.

Retrieve the file via Cache.getBinary(key).

The URL can be relative or absolute. If the URL is relative the Loader.baseURL and Loader.path values will be prepended to it.

If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "alien"
and no URL is given then the Loader will set the URL to be "alien.bin". It will always add .bin as the extension.
If you do not desire this action then provide a URL.

It will be loaded via xhr with a responseType of "arraybuffer". You can specify an optional callback to process the file after load.
When the callback is called it will be passed 2 parameters: the key of the file and the file data.

WARNING: If a callback is specified the data will be set to whatever it returns. Always return the data object, even if you didn't modify it.

Parameters
Name Type Argument Default Description
key string

Unique asset key of the binary file.

url string <optional>

URL of the binary file. If undefined or null the url will be set to <key>.bin, i.e. if key was "alien" then the URL will be "alien.bin".

callback function <optional>
(none)

Optional callback that will be passed the file after loading, so you can perform additional processing on it.

callbackContext object <optional>

The context under which the callback will be applied. If not specified it will use the callback itself as the context.

Returns

This Loader instance.

Source code: loader/Loader.js (Line 911)
doc_phaser
2017-02-14 10:54:19
Comments
Leave a Comment

Please login to continue.