How do I give player a power up only once when available?

Get help using Construct 2

Post » Sat Nov 05, 2016 12:18 am

I'm working on game achievements, and hopefully the logic will carry over to the store.

When the player's ball collides with a star, 1 is added to the GV StarCount. When the StarCount is greater/equal at certain levels the player gets an achievement, and a certain number of shields is added to the GV Shields: starcount = 250 - 1 shield, starcount = 500 - 2 shields, etc. etc...

How can i make the ball spawn a shield only once for every point the GV Shields has?

And wouldn't I need to set the Shields to localstorage?


Thank you for any help with this. It's been turning my brain to mush.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Post » Sat Nov 05, 2016 12:57 am

You might be able to get away with just a "Trigger once while true" or a "Start of layout" condition followed by a "Repeat X times" sub-event, unless I'm misunderstanding.

On start of layout
- Repeat [GV Shields] times --> Spawn shield

This way the loop only runs once at the start. And yeah, you'd need to save your Shields value if you want it to persist after you close and reopen the game.
B
53
S
24
G
18
Posts: 295
Reputation: 13,115

Post » Sat Nov 05, 2016 1:21 am

Sup with that? wrote:You might be able to get away with just a "Trigger once while true" or a "Start of layout" condition followed by a "Repeat X times" sub-event, unless I'm misunderstanding.

On start of layout
- Repeat [GV Shields] times --> Spawn shield

This way the loop only runs once at the start. And yeah, you'd need to save your Shields value if you want it to persist after you close and reopen the game.


Thanks for the reply.

I'm trying to get the shield to spawn during gameplay, while the ball is visible. If the ball falls off a disk, it is destroyed - GAMEOVER. If the ball has the shield when it dies, the shield is destroyed also, and 1 subtracted from the GV Shields.

I got the achievement to trigger, but no shield....yet.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Post » Sat Nov 05, 2016 1:28 am

Try to put it on local storage. Global variables is your best friend in your problem. If you want to show the shield only once. try Trigger once while true and put more condition in to it. i hope i helped you.
B
79
S
31
G
7
Posts: 148
Reputation: 9,179

Post » Sat Nov 05, 2016 2:22 am

In that case maybe run a check to compare the variable to the number of shield objects for when it's time to spawn them.

Shield.Count < GV Shields --> Spawn Shield
B
53
S
24
G
18
Posts: 295
Reputation: 13,115

Post » Sat Nov 05, 2016 4:30 pm

clarkkentnicdao wrote:Try to put it on local storage. Global variables is your best friend in your problem. If you want to show the shield only once. try Trigger once while true and put more condition in to it. i hope i helped you.


Sup with that? wrote:In that case maybe run a check to compare the variable to the number of shield objects for when it's time to spawn them.

Shield.Count < GV Shields --> Spawn Shield


Thanks for the help. I've been trying to add and change things around, unfortunately, i still haven't been able to find a way to get the shield to spawn. I've been trying to set the Shield localstorage to 0 or to clear the storage, since the Stars count keeps resetting or going up.

This is what i have so far CAPX

I still have some things to work out, though. Like getting the HighScore textbox to show if the total score is higher than the high score...among other things.

Sometimes it's hard for my brain to comprehend things, like studying trigonometry in chemistry class.

Again, thanks for the replies, and thank you so much for any help.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Post » Sat Nov 05, 2016 6:45 pm

I can't see any hint of a shield in the game, where is it? I can see a global variable called magnashield but nothing adds to it and I can't see a shield asset.
B
47
S
17
G
81
Posts: 2,225
Reputation: 48,097

Post » Sat Nov 05, 2016 7:00 pm

plinkie wrote:I can't see any hint of a shield in the game, where is it? I can see a global variable called magnashield but nothing adds to it and I can't see a shield asset.


Thanks for replying. Look at the Assets layout..the gold ring.

The events (until i learn how to do them for the 'Store' purchases) will be under achievements.

I may have been going back to try and edit and or learn how to do it when i uploaded the capx.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Post » Sat Nov 05, 2016 7:26 pm

Well at the moment it's not spawning because you've not included your achievements event sheet in gameplay_common..once included it spawns the shield and works fine. What are you trying to do from this point?
B
47
S
17
G
81
Posts: 2,225
Reputation: 48,097

Post » Sat Nov 05, 2016 8:10 pm

plinkie wrote:Well at the moment it's not spawning because you've not included your achievements event sheet in gameplay_common..once included it spawns the shield and works fine. What are you trying to do from this point?


Dang...easily overlooked. Sorry @plinkie.

I had a problem with the shields spawning for each point in the GV MagnaShield. I could only get it to spawn all of them at once, or only a single time.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Next

Return to How do I....?

Who is online

Users browsing this forum: Lancifer and 20 guests