I see documentation for the WADE API. Is there any documentation for the ITS and WSC file formats or do I need to figure them out via trial and error?
First of all let me note that if you are using a tool such as TexturePacker to create your sprite sheet, there are exporters that can save your data in the right format directly (see this blog post), without you having to worry about the structure of WSC and ITS files.
Having said that, if you look at the documentation for wade.importScene(...) it describes the general structure of a WSC file.
Since you are making an isometric game, you probably only care about the "modules.iso" part of it, which isn't very well documented, but shuld be straightforward.The isometric map data is stored in modules.iso.terrain and contains data in this format:
{
"numTilesX": 2,
"numTilesZ": 2,
"tileData":
[
{"texture": "grass.png"},
{"texture": "sand.png"}
],
"tileDataIds":
[
[0, 0]
[1, 0]
]
}
As you can see tileData contains the definition of all the tile types (a grass tile and a sand tile in this example), whereas tileDataIds describes how these tile types are layed out on the map - 3 grass tiles (type 0) and sand in one corner (type 1). A value of -1 represents and empty tile.
Additionally you will have transitionData and transitionDataIds which work in the same way, but are for the next layer, above tile data. It's a layer that's usually used with semi-transparent PNG's for smooth transitions between different tile types. However it's up to you how you want to use it, or you can choose not to use it at all.
There are also detailData and detailDataIds, which again work in the exact same way, and are used for yet another layer (normally to add small-scale details).
Finally you have tileHeight which is a bi-dimensional array describing the height of each tile, and it's full of zeroes for a flat map.
Now for your objects, you have some data structures that define your objects (see the documentation of wade.iso.createObject for a complete description of this data structure). An ITS file is a collection of such data structures, stored in an array called tiles.
When you place objects on the map, their data structures are copied in modules.iso.gameObjectData (which is an array of objects).
For each object that you have on the map, an entry is added to modules.iso.gameObjects (again, an array of objects). Each one of these entries looks like this:
{
"templateId": 0,
"gridCoords": {
"x": 2,
"z": 1
},
"instanceData": {
"name": "example_object",
"life": 25
}
},
where templateId tells you what's the index of the object's data structure in the gameObjectData array; gridCoords tells you where this instance of the obejcts is on the map; and instanceData contains any number of properties that you want to attach to this instance of the object.
I hope this helps
Thank you! I was looking for this. A couple things still aren't clear to me though. How far do these data file on the tiles and the objects go towards actually rendering the scene? It seems like calls to create new Sprites and SceneObjects still have to be made to render the map. Does the isometric engine make that automatic in any parts?
When you call wade.loadScene, all the SceneObjects that are defined in the WSC are automatically added to the scene - unless you have changed their AddToScene property and set it to false.
This applies to all the SceneObjects in the WSC file's sceneObjects array (these are regular 2D scene objects that are internally created by calling new Sprite, new SceneObject, wade.addSceneObject etc). And it also applies to isometric objects stored in the WSC file's modules.iso.gameObjects array (these are isometric objects that are created internally using wade.iso.createObject).
As long as the objects are in the WSC files, they are automatically created when loading the scene, you don't need to write any additional code.
I've been playing around with the wade.iso code. I want to be able to build new objects during the game. But when I calle the wade.iso.createObject function, and give it a sprite in the objectData, it doesn't appear anywhere in the scene, even though it returns a SceneObject. I'm not sure what I'm doing wrong.
Nevermind. Resolved my problem in another thread.