How do I save the game state for undo/redo

Get help using Construct 2

Post » Mon Jun 15, 2015 6:50 pm

I would like to save the last 10 entire game states to the memory - not to a local storage! I tried to use the "Dictionary" to implement this, but it doesn't work properly!

Do I have to use the local storage to save the entire game state for the undo/redo? or can I use the dictionary to do this?

Note: I just need the saved game states for the "undo/redo" during the game play!

May you advise please?
I'll be so much appreciated if you could send me a simple capx for this!

Thanks in advance!
B
20
S
6
Posts: 10
Reputation: 1,222

Post » Tue Jun 16, 2015 11:40 am

Just solved it. Hurray a time machine
Image

undo-redo_block.capx
warning: no array get involved

Undo-redo feature is common mechanic in various puzzle game. The example showing how block movement can be undo or redo. The concept is very simple; Each time player drag the block to a new position, the information are stored into dedicated separate text object by append x and y value.

When the player need to cancel or recall last position, the system just need to iterate using tokenat. Even the system updated in the middle of interfere. I had this solution around my head, but just actuate it just now. :geek:
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480

Post » Tue Jun 16, 2015 5:19 pm

Thanks alot @alextro for your reply and capx!

But my game is something like dress-up games. I have many objects, each object has its own properties (width, height, frame number, animation, scale, color, .. etc) - not only the position of one object
And I need to detect user actions as (rotate, duplicate, delete, etc .. ) to be able to undo/redo!
So I think in saving the entire game state once an action happen by somehow!

Any ideas?
B
20
S
6
Posts: 10
Reputation: 1,222

Post » Tue Jun 16, 2015 8:25 pm

The simplest way to get you want is just use save option. Each time player make a change, system will trigger saving action into an iteration name like "save1", "save2", etc, adding 1 into a variable value. To move back & forth between changes, my undo-redo example did that exactly. You just need to replace the x or y value into save slot then load them when needed.

So make sure you make entire save-trigger system record every changes made by player and only at certain condition such as ' isn't touching object, trigger once'.
ImageImage
B
114
S
51
G
24
Posts: 790
Reputation: 23,480

Post » Tue Jun 16, 2015 9:40 pm

Great, I will try to do it this way.
Thank you so much @alextro!
B
20
S
6
Posts: 10
Reputation: 1,222


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 7 guests