capture game object x/y location

I need to be able to capture the x/y location of multiple objects on the active game board at save time so the user can return to the game either after a pause/system time out event or from a hard stop (exit) cold start and have the board and objects ready to continue with game.

So far I have found nothing that points me in the right direction.

A followup, may have answered my own question. Grandchildren make demands that must be obeyed :slight_smile:

So I have a function gameObject that holds all of the game items, the board, static object and the moving objects. If on save game I set the board and static objects to nil and then save the gameObject with only the active objects still defined will that give me a file that holds the current location of these objects for restore?

The other objects do not need to be saved as their display is dependent on the active players level and are loaded from lua tables hold the png names an coordinates. The level, score, standing, gems earned etc are saved off in another file.

True, you only need to save the positions of things that have moved or changed in some way.  For instance in a role playing game you need to not only have your hero’s x, and y, but his health, what weapons he has, etc. 

Now saving the object itself may seem like the logical thing to do, but the object is generally made up of some image. That image has to be re-receated. It can’t be saved per-se.  You will probably need a data object for each image object in use and the data object holds the state of all the things you can set (x, y, health, coins, etc.) for that object. Then you can use various techniques to save that data table.

Rob

do then the data object exists in parallel to the game object?

You would have to create the data object, but honestly I wouldn’t during game play, but have a list of objects that need to be saved and when it comes time to save them, make a table of data bits to save.  When you need to resume the game fetch the data, re-create the objects and set the properties back from the read data table.

Rob

A followup, may have answered my own question. Grandchildren make demands that must be obeyed :slight_smile:

So I have a function gameObject that holds all of the game items, the board, static object and the moving objects. If on save game I set the board and static objects to nil and then save the gameObject with only the active objects still defined will that give me a file that holds the current location of these objects for restore?

The other objects do not need to be saved as their display is dependent on the active players level and are loaded from lua tables hold the png names an coordinates. The level, score, standing, gems earned etc are saved off in another file.

True, you only need to save the positions of things that have moved or changed in some way.  For instance in a role playing game you need to not only have your hero’s x, and y, but his health, what weapons he has, etc. 

Now saving the object itself may seem like the logical thing to do, but the object is generally made up of some image. That image has to be re-receated. It can’t be saved per-se.  You will probably need a data object for each image object in use and the data object holds the state of all the things you can set (x, y, health, coins, etc.) for that object. Then you can use various techniques to save that data table.

Rob

do then the data object exists in parallel to the game object?

You would have to create the data object, but honestly I wouldn’t during game play, but have a list of objects that need to be saved and when it comes time to save them, make a table of data bits to save.  When you need to resume the game fetch the data, re-create the objects and set the properties back from the read data table.

Rob