Making a coin collection system

0 favourites
  • 4 posts
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • 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!

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • 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!

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