Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Content XML Encoding

Nathaniel Nelson edited this page Oct 17, 2013 · 1 revision

You can encode the content of your game in XML files and use JavaLib to automatically load the content.

SpriteSheet XML

The format for encoding your game's SpriteSheet is as follows.

All information is wrapped in an XML element:

<SpriteSheet>

    ...

</SpriteSheet>

The SpriteSheet texture's internal file path must be encoded as a child anywhere within the SpriteSheet element. For example:

<texture>data/spritesheet.png</texture>

The SpriteSheet's source rectangles are each encoded in elements with the name "rect", a key attribute, and their x, y, width and height within the element, as follows:

<rect key="Player">0, 0, 8, 8</rect>

Initialize your game's SpriteSheet using the static fromXML() method, which takes only a FileHandle parameter, as follows:

SpriteSheet spriteSheet = SpriteSheet.fromXML(Gdx.files.internal("data/spritesheet.xml"));

Note that after initialization you can still add source rectangles manually using SpriteSheet.addRegion(), although this is not recommended.

Clone this wiki locally