How do I record the coins?

0 favourites
  • 6 posts
From the Asset Store
112 High-Quality Coins and Chest SFX specially crafted for video games
  • Mobile game / C3

    Saving the level works great, but I'm doing something wrong when saving the coins and I can't figure out what it is.

    When I exit the game and come back in the levels are correct, it's right where I left it, but the coins are reset to 0.

    Anyone see what I'm doing wrong?

    Menu Event Sheet

    Game Event Sheet

  • All three events on your second screenshot are executed every tick - about 60 times per second. It's not recommended to write to (or read from) Local Storage on every tick. You need to make sure that "Set item" actions are only executed once when the level is completed.

    Also, you can remove all "Get item" actions from the first screenshot, they are not required.

  • dop2000,

    Disregard - I got it.

    Thanks.

    Original:

    I'm confused. Why do you say "second screenshot are executed every tick - about 60 times per second. It's not recommended to write to (or read from) Local Storage on every tick." (I'm assuming it's because you know me so well lol)

    I don't think they're writing to the local storage every tick. Is that something I did or something that happens with one of the events I have set?

    Thank you

  • I assume the events on the second screenshot are top-level events, not nested under anything else?

    While win=1 condition is true, the first event will fire on every tick and the data in LS will be overwritten. (Unless there is some other event, which immediately changes win variable from 1 to something else)

    The third event on the screenshot may also be executed multiple times, because you are using continuous condition "Is touching" instead of the "On touched" trigger.

    Local Storage operations are asynchronous, you need to be careful not to run them on every tick. And make sure that you are not attempting to read from LS before writing operation has finished.

    If you send me your project file, I'll help you to fix it :)

  • dop2000,

    Thank you, I think I got it. I'd send over the c3p, but it has so many plugins it would be a hassle.

    However, if you want to try the game, it's a 3D 360 demo at the moment. It activates your phones camera and you need to destroy .... well everything that pops up ... by pressing the blue button on the right.

    iticka.com/TCGDemonRealm7

    If you want 50 coins, just press the coin on the bottom right of the game screen.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Whoa! I don't understand what's going on, but it looks really cool!

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