Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Save and load attribute (coin counter)

Hi all,

I'm stuck on setting up coin counter attribute.
In my game scene, my actor collects coins, I've set up save 'coin counter' and 'load coin counter' at the end and beginning, and it worked fine.
In my store scene, I need to set up buy item option, and once the item is purchased change 'coin counter' to 'coin counter-10'.
I've also set up save and load coin counter in this scene.
The problem is after I purchased the item and went back to play the game, 'coin counter' did not reduce, which I reckon the load and save rule in store scene did not affect the game scene.
Can anyone help to solve the problem?

Thanks in advance.


  • awesome_wellsawesome_wells Member Posts: 37

    Hi @honeymimi56,

    Does the coin counter attribute exist in the actor or as a game level attribute?

    If you set the counter as a global (game) attribute, then there should be no need to load/save it between scenes.

    I only use the load/save behaviour to save changes to attributes that I want to keep for when the player returns to the game after closing it (e.g. High score).

    I hope that helps!

  • ArmellineArmelline Member, PRO Posts: 4,856

    @honeymimi56 This sounds like you might need to post some screenshots of the logic you're using. For what you're doing, you'd normally want the following actions:

    • Load coins on the first scene of your game (only the first one) - if you have a single scene game, you might need this to only happen on the first launch of the game.
    • Save coins at the end of each game (or as each coin is collected).
    • On your shop scene, you need to have a -10 coins change attribute, when the purchase is completed.
    • Once you do the -10, you should Save the coin total.
    • You do not want a load on the shop scene, and you want to be sure the load is not triggered when you exit the shop.

    I suspect your problem has a simple solution, but it might be tricky to find where the problem is without seeing your logic. If you don't find the solution, feel free to add me on Skype and we can take a look.

  • honeymimi56honeymimi56 Member, PRO Posts: 24

    Thanks guys. @Armelline @awesome_wells

    I tried to only save and load the coin number in game scene. However, when the purchase is done in the shop, the coin number would't reduce in the game.
    What I did for now is save and load the coin number in the shop as well, but use the same key as in the game. now it seems everything is working. But @Armelline suggested I should not load coin number in shop, could you please elaborate more?
    I have attach a screen shot below. Please help to have a look.

Sign In or Register to comment.