atlasXML(key, textureURL, atlasURL, atlasData) → {Phaser.Loader}
Adds a Texture Atlas file to the current load queue.
This call expects the atlas data to be in the Starling XML data 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 an xml file.
Or you can pass in an XML object or String via the atlasData
parameter.
If you pass a String the data is automatically run through Loader.parseXML
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)
. XML files are automatically parsed upon load.
If you need to control when the XML is parsed then use Loader.text
instead and parse the XML 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.xml".
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> | An XML 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 1490)
Please login to continue.