How do I save the game state for undo/redo

0 favourites
  • 5 posts
From the Asset Store
State Machine
$10.99 USD
State Machine is a great tool for managing the state of anything in your game.
  • 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!

  • Just solved it. Hurray a time machine


    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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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'.

  • Great, I will try to do it this way.

    Thank you so much alextro!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)