-
Notifications
You must be signed in to change notification settings - Fork 0
Content XML Encoding
You can encode the content of your game in XML files and use JavaLib to automatically load the content.
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.