For my game, it's necessary to collect three coins on each level in order to complete the level and progress to the next. I'm not sure what method I would use to do this. How can I make it so that the amount of coins is detected so that once there are none, you can move on?
Offline
deerprince wrote:
For my game, it's necessary to collect three coins on each level in order to complete the level and progress to the next. I'm not sure what method I would use to do this. How can I make it so that the amount of coins is detected so that once there are none, you can move on?
One way you could do this is to have a variable called coins. Now, whenever you start a level, you set it to 0. Also, whenever a coin touches you, it'll change that varibale by 1 and hide. Finally, the last thing needed is to create a script to detect when you've hit three coins (which can be done through a conditional involving the variable coins) and to set the stage for the next level, which could be done through broadcasts. If you need an actual script for any of these parts, just say.
I hope that this helps! Also, hello deerprince and welcome to scratch! I wish you a wonderful time here!
Last edited by ErnieParke (2013-01-11 19:17:30)
Offline
Depends on the exact specifications of your game but I would use:
(for the player)
when gf clicked set [CoinCount v] to [0] forever if <touching color [#D9E01B]?>//Colour of coins change [CoinCount v] by [1] end if <(CoinCount)=[3]> broadcast [NextLevel v] change [Level v] by [1] set [CoinCount v] to [0]For the coin sprites:
when gf clicked show forever if <touching [player v]?> hide when i receive [NextLevel v] show
Last edited by PhirripSyrrip (2013-01-11 19:23:13)
Offline
Thank you both! I tried it out and it works fine for my game.
Offline
deerprince wrote:
Thank you both! I tried it out and it works fine for my game.
Happy to Help
Offline
deerprince wrote:
Thank you both! I tried it out and it works fine for my game.
Your welcome!
Offline