Alexander Ovchinnikov
Alexander Ovchinnikov

Reputation: 363

How to save Sprite objects to file in cocos2dx?

How can I serialize and de-serialize Sprite objects in Cocos2dx (efficiently preferred)?
The main purpose of it for me is that I want to save my current game state. I have several game objects with related Sprites on the game scene. So I need somehow to store these objects into the file and restore them back after some time(for example after relaunch application).

Upvotes: 0

Views: 177

Answers (1)

ZeroZerg
ZeroZerg

Reputation: 457

What you need to save is only the values which indicate the current game state.

Use CCUserDefault(2.x) to do the job, it is a class which used for saving some information.

When you need to restore the game state. Load the values from CCUserDefault and recreate the scene base on them.

Upvotes: 1

Related Questions