Loader#atlasXML()

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:

Texture Packer
Shoebox

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 null the url will be set to <key>.png, i.e. if key was "alien" then the URL will be "alien.png".

atlasURL string <optional>

URL of the texture atlas data file. If undefined or null and no atlasData is given, the url will be set to <key>.json, i.e. if key was "alien" then the URL will be "alien.xml".

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)
doc_phaser
2017-02-14 10:54:17
Comments
Leave a Comment

Please login to continue.