How do I save my progres?

0 favourites
  • 7 posts
From the Asset Store
Match the similar cards with each other and free all animals!
  • Hello everyone!

    I was been working on an idleRPG game for a long time, in which the player develops his character, gains items and, as it happens in idle games, becomes stronger with every hour spent in the game.

    I've already done a lot of work, and the game is starting to look right. So it's time to work on changing the character's location, for example going from sewers to shelter, and then the player can choose the location they want to move to again.

    And here is where the problem arose, and I have no idea how to solve it.

    When changing the location (layout), the player loses all progress. Lose hiss statistics, items etc.

    working on layouts, things like equipment, player stats are in separate layouts, the player by pressing/clicking the appropriate button brings them to his screen.

    Now my question is, is it possible to fix this somehow at this stage, or will I have to create the game from scratch in a different way?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Where do you currently store this progress? Is it in instance variables on the player sprite, or in global variables?

    With global variables, the progress should not reset when you switch between layouts. Unless you perform "Reset global variables" action, in which case - don't :)

    You can also use a Dictionary to store things like player stats, gold, scores etc. One advantage of dictionaries is that they can easily be saved in Local Storage.

  • I create instance variables on sprites like player, items and enemy. What is best solution to keep that information betwen layouts?

  • Most common method is to use global variables for values which you need to be available across multiple layouts. You can also use dictionaries, arrays, JSONs.

  • Yea but player object have a lot of instance variables Its is good to "transform" them to global?

    And about dictionares, there is some tutorial because im looking on yt and dont find any thing about how to use them?

  • You don't have to transform all instance variables to global. Only those which need to be preserved when switching layouts.

    Working with Dictionary is easy and not much different from global variables.

    You can give any names to dictionary keys. For example:

    Dictionary set "lives" to 5

    Dictionary set "score" to (self.get("score")+100)

    Dictionary Compare "lives" value=0 : Player play animation "death"

    etc.

    There are probably some tutorials and lessons on how to use dictionaries, try googling.

  • Another option is to keep using instance variables on the Player sprite, but make the Player sprite global.

    The global instance of the Player sprite will automatically move to another layout with all its instance variables. All you need to do is set its position and maybe move to the correct layer.

    You need to be very careful - keep only one copy of the Player in the project (put it on the first layout), don't create new instances and don't destroy it. It's very easy to make a mistake and end up with multiple instances of the object, which will cause all kinds of bugs. That's why I don't recommend this method.

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