How do I manage variables in a turn based game in between load/save game?

0 favourites
  • 4 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • I'm trying to make a little pokemon-like rpg, where I meet some enemies on my way, and I've to store some variables changes after the battle.

    Practically, I need to store and change informations (variables) about how many enemies of a certain type I killed and how many of them I "forgive".

    The point is, when the battle finish, I want to restart from the same point where I was before meeting the enemy, so now my logic is this: collision with an enemy -> "save game" -> go to layout "fight" -> load last game save.

    With this logic, if I change any of the global variables during the fight, I'll lose the changes when I load the last game save.

    Would a workaround be not using the save/load game, but storing in variables the position of the player before the collision with the enemy?

    What could I do to store variables during the fight so I can access them after the loading too?

    What would be your workaround?

  • There are several ways to do this:

    1. Create a dummy object (an empty sprite for example), set it as Global and add No Save behavior. Move all your global variables to instance variables on this sprite.

    2. Save these variables to Local Storage. After loading a saved game, retrieve variables from Local Storage.

  • There are several ways to do this:

    1. Create a dummy object (an empty sprite for example), set it as Global and add No Save behavior. Move all your global variables to instance variables on this sprite.

    2. Save these variables to Local Storage. After loading a saved game, retrieve variables from Local Storage.

    Can you make a demonstration of this to look over? I think I might have tried to do something like this before and wasn't sure it was working.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000 I got your point! Actually, I didn't understand before (reading the manual) if local storage was saved or not.

    I think the easiest way is by using the dummy object with no save, this is something I've never heard of and that I would have never thought.

    Thanks a lot for the precious suggestions!

    YoHoho tomorrow I'm gonna try one of the methods and I can share here the demonstration (screenshots of the events, because unfortunately at the moment I have no time to make a demonstration capx) of what I'll do if you want.

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