help with loading a saved isometric scene

Hi, sorry about all these questions --

I'm trying to save and load an isometric game scene. To do this, I use the following code, based on the .wsc files I see when I play around in the WADE editor:

let exportedScene = wade.exportScene();
exportedScene.sceneObjects = _.filter(exportedScene.sceneObjects, (obj) => {
    return ! _.has(, 'iso'); 
exportedScene.modules = {
    iso: wade.iso.exportMap() 
wade.storeLocalObject('save_game', JSON.stringify(exportedScene));

Then to load it, I do the following:

let savedGame = JSON.parse(wade.retrieveLocalObject('save_game'));
wade.setJson('savedGameScene.wsc', savedGame);

wade.loadScene('savedGameScene.wsc', true, () => {
}, true);

But what I'm noticing on the console is that the new exported isometric map has no gameObjectData or gameObjects. On screen, it is the same: no gameObjects. The only thing that was loaded was the tile and transition sprites.

Do you have any idea what might be causing this? Or is there a more appropriate way to save and load an isometric game scene?

All 4 Comments

So I've found one cause. When creating isometric objects with wade.iso.createObject, the objectData parameter has a 'sprites' property that can either be the data object for a single sprite, or an array of sprite data objects.

Originally, I used a single sprite data object for the 'sprites' property. But after using the debugger, I believe this causes wade.importScene() to fail to load all such sprites, because it ASSUMES that in the isometric gameObjectData, gameObjectData[0].sprites is an array and has a length property, which a single sprite data object does not have.

Once I changed the 'sprites' property in my code to be an array containing a single sprite data object, saving and loading a game, as described in my code above, began to work better: the terrain loaded AND all the game objects loaded.


Sorry for such a poor bug report. I'm a little pressed for time right now on the game.


I'm noticing that after loading the game, even though all the game objects are now present, none of the animations were saved with them.

After I examine each isometric SceneObject, I see that the animations ARE stored in SceneObject._sprites[i].animations, but not in SceneObject.iso.objectData.sprites[i]. This may be because I added each animation AFTER calling wade.iso.createObject by using SceneObject.getSprite(0).addAnimation. Similarly, every sprite I added to an isometric object using SceneObject.addSprite is not saved in the isometric data, and doesn't show up when I load the game.

I will try to address these by adding all animations and sprites to the objectData before calling wade.iso.createObject. If that fails, I may try simply assigning SceneObject.iso.objectData.sprites = SceneObject._sprites, although that could be dangerous, I don't know.

Probably you already know about this problem and will fix it in the next versions of WADE (when 'new SceneObject()' can be used to create isometric objects as well), but I thought I would note it anyways.


Well yes, everything is going to change in version 4.0. But for now, let me clarify how it works at present.

Isometric objects are created based on "template" data; by this I mean that the objectData parameter contains data that should be the same for all objects of the same type. This is to avoid lots of duplicate data structures, so for example if you have 100 trees of the same type, you have one single definition of the tree data, and everything else is a copy of that.

You can extend each object with some data that is specific for each instance of the object. This is the instanceData parameter that you pass to wade.iso.createObject. This may include any custom properties that you want to attach to the object.

You can add more such properties after the object has been created, for example you could do

myObject.myOwnProperty = 'someValue';

When you then go to export the map, WADE should be smart enough to recognize these properties and add them to the instanceData for each of your objects.

This, however, works for SceneObject properties, but not for Sprite properties (and therefore, not for Animations).

This is how it works, and I agree that it is confusing. I think that the disadvantages of this approach actually outweigh the benefits of not having to duplicate the data. So this is all changing soon.

Post a reply
Add Attachment
Submit Reply
Login to Reply