Help with fixing a major Global Variable localstorage issue?

Get help using Construct 2

Post » Wed Nov 09, 2016 10:21 pm

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 @plinkie 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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Wed Nov 09, 2016 10:48 pm

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
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Wed Nov 09, 2016 11:23 pm

Thanks again, @plinkie

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.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Thu Nov 10, 2016 12:37 pm

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.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396


Return to How do I....?

Who is online

Users browsing this forum: stevenode, Yahoo [Bot] and 7 guests