• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

saving with a parent object

I followed a tutorial to save objects and it said that if I gave each object the same parent object it would still load the individual objects correctly. However when I save and load, it loads every object as the parent object. Is there something I did wrong? Here is the save code and the load code. pSaveMe is the parent object.

Save Code:

with (pSaveMe)
{
var _saveEntity =
{
obj : object_get_name(image_index),
y : y,
x : x,
//spd : spd,
image_index : image_index,
image_blend : image_blend,
}
array_push(_saveData, _saveEntity);
}

Load Code:

var _loadData = json_parse( _string);

while (array_length(_loadData) > 0)
{
var _loadEntity = array_pop(_loadData);
with (instance_create_layer(0,0,layer,asset_get_index(_loadEntity.obj)))
{
x = _loadEntity.x;
y = _loadEntity.y;
image_blend = _loadEntity.image_blend;
image_index = _loadEntity.image_index;
//spd = _loadEntity.spd;
}
}
 
Top