Making a coin collection system

Get help using Construct 2

Post » Fri Dec 21, 2012 1:20 am

Before you say "Global Variables" hear me out.

My game is utilizing an Angry Birds like interface, each level I'd like to make a part where you collect 20 coins per level and you get a gold completion for that level. I have it figured out on how to make the level finish using arrays, but for the coins I've gave the object an instance variable but it doesn't seem to add towards the amount.

It only seems that the global variable idea works, but I can't uncheck "static" because I want the player to get all 20 coins every level playthrough instead of get a few, and get another few in another level and it messes up the whole thing.

So to summarize, how do I make it to where the player collects a fixed amount of coins in each level?

Thanks for reading!
Image
B
13
S
4
G
3
Posts: 116
Reputation: 3,731

Post » Fri Dec 21, 2012 1:52 am

Have an array to tell you how many you need on each level. On the title screen you can add an even where you fill all the array values with the number of coins for each level.

The array width is the number of levels, and the height should be 2, one for the number of coins on the level, and the other to count the number the player got.

So each time the player gets a coin, you do
array.at(level, 1) = array.at(level, 1) + 1
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Fri Dec 21, 2012 4:17 am

If you're saying that after they player gets 20 coins and they go to another level, you want the player to have 0 coins not 20? In that case, just put this event:
Event: End of Layout; Actions: Set 'coins' to 0
B
29
S
7
G
3
Posts: 361
Reputation: 6,187

Post » Wed Dec 26, 2012 4:05 am

Thanks guys, I know it's been a few days but Invaders idea works great with the global variable. I'm kicking myself for not trying this sooner. I've added the "0 Coins" triggers at the end of the level and in the case of the player backing out to the level select. Tried the array idea, but was still having trouble so I'll stick with the arrays I have set for each act/world and the main hub.

Another problem solved, thanks!
Image
B
13
S
4
G
3
Posts: 116
Reputation: 3,731


Return to How do I....?

Who is online

Users browsing this forum: agittm, mercuryus and 17 guests