atlasJSONHash(key, textureURL, atlasURL, atlasData) → {Phaser.Loader}
Adds a Texture Atlas file to the current load queue.
Unlike Loader.atlas
this call expects the atlas data to be in a JSON Hash format.
To create the Texture Atlas you can use tools such as:
If using Texture Packer we recommend you enable "Trim sprite names".
If your atlas software has an option to "rotate" the resulting frames, you must disable it.
You can choose to either load the data externally, by providing a URL to a json file.
Or you can pass in a JSON object or String via the atlasData
parameter.
If you pass a String the data is automatically run through JSON.parse
and then immediately added to the Phaser.Cache.
If URLs are provided the files are not loaded immediately after calling this method, but are added to the load queue.
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.getImage(key)
. JSON files are automatically parsed upon load.
If you need to control when the JSON is parsed then use Loader.text
instead and parse the JSON file as needed.
The URLs can be relative or absolute. If the URL is relative the Loader.baseURL
and Loader.path
values will be prepended to it.
If the textureURL isn't specified then the Loader will take the key and create a filename from that.
For example if the key is "player" and textureURL is null then the Loader will set the URL to be "player.png".
The same is true for the atlasURL. If atlasURL isn't specified and no atlasData has been provided then the Loader will
set the atlasURL to be the key. For example if the key is "player" the atlasURL will be set to "player.json".
If you do not desire this action then provide URLs and / or a data object.
Parameters
Name | Type | Argument | Description |
---|---|---|---|
key | string | Unique asset key of the texture atlas file. | |
textureURL | string | <optional> | URL of the texture atlas image file. If undefined or |
atlasURL | string | <optional> | URL of the texture atlas data file. If undefined or |
atlasData | object | <optional> | A JSON data object. You don't need this if the data is being loaded from a URL. |
Returns
This Loader instance.
- Source code: loader/Loader.js (Line 1444)
Please login to continue.