Now lets take a look at how we parse the data to generate Booty5 compatible objects:

1

2

3

4

5

// Create XOML loader

varxoml=newb5.Xoml(app);

// Parse and create global resources placing them into the app

xoml.parseResources(app,xoml_globals);

Post Loading Scenes

In the Booty5 game editor you can mark scenes as “do not load” which means they will not be parsed when the app begins. At a later date you will need to load this exported scene XOML, the example below shows how to do this:

1

newb5.Xoml(app).parseResources(app,xoml_data);

In the above example we create an instance of the Xoml class then call parseResources(), passing in the app as the place to put global resources and the object that contains the XOML JSON data. Note that all exported scenes data is placed in the b5.data object, so accessing for example a scene called level1 you would pass [b5.data["level1"]] as xoml_data.

Creating Resources from XOML templates

You can create a copy of any object / resource that exists in the XOML JSON data, you can think of the XOML data as a collection of templates. Lets take a quick look at an example:

In the above example we find the XOML template for the ball actor. We create an instance of the Xoml class that parses this template and creates a ball Actor object from it. We pass in the scene that contains resources that the ball object is dependent upon, such as bitmaps, timelines etc… Finally we modify the generated Actor object to add our own changes, such as give it a random fill style, a position and a velocity.