Help with fixing a major Global Variable localstorage issue?

0 favourites
  • 4 posts
From the Asset Store
Globals 2.0
$3.99 USD
Globals 2.0 stores and group variables. You can also load and save data (variables) from/to JSON files.
  • I have been trying to fix some major issues with within my game. Tried following tutorials, examples, helpful posts...still can not figure this out. Starting to get frustrated and feel a little stupid.

    The basics:

    You roll a ball over disks that have stars on them.

    When you collide with the stars you get points.

    When you score enough stars, certain achievements trigger and you gain a certain number of shield power-ups (100 stars = 1 shield. 200 stars = 2 shields etc. etc.) and a shield should spawn at the exact moment.

    If you die with a shield equipped, another shield should spawn when the ball is created, if there are more shields available, but it doesn't.

    With the help of i was able to get the shield to spawn when the achievement triggers. But now when you die, if you have a number of shields, the shield count would go to a negative number or go to zero.

    My problem, and where i know i am getting confused and feel so stupid, is synchronizing the localstorage with the Global Variable's, and ultimately with the logic that goes with it.

    Some info on the capx - I have the achievement triggers set low for the stars, this is only so that it's faster to test. Also, on the Menu event sheet there is an action to 'clear storage'. I enable this, run the menu layout and then before i test i go back and disable that 'clear storage' action so the localstorage will save. Then I run the Menu layout again. Just makes things a bit easier, for now and at least for me.

    CAPX

    If anyone could take a look, and help a numb-skull out with this frustrating problem, it would be greatly appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • On gameplay-player event 14 the balldeath function, it runs it several times while those things are true. Add a trigger once sub event for calling function balldeath

  • Thanks again,

    I changed that. But now, when the ball is destroyed a random number will be subtracted from the shield count. i.e 10-3, 10-6, 10-5,etc. etc.

    Also, if the StarsCount is at <5 and you roll over stars that are on top of one another to get equal or greater than the achievement that triggers the 1st shield count, it will not trigger.

  • You use trigger once strangely. You're supposed to put the action next to the trigger once event, like on the same line for it to trigger once if you put it as a sub event. You don't need to do this if you have it as a condition as there won't be another line anyway. There are a few tweaks you need. In achievements bring achievement 1 down to the trigger once line. Event 7 where you're adding 10 to magnashield you need to make that trigger once only as well. If you run this in debug you can see the global variables that are increasing massively because the events are constantly true and weren't triggered once only.

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