This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-11 19:10:02

deerprince
New Scratcher
Registered: 2013-01-11
Posts: 2

Collecting items?

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

 

#2 2013-01-11 19:16:45

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Collecting items?

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.  wink

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)


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2013-01-11 19:20:45

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: Collecting items?

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)


http://i46.tinypic.com/ao03lk.png

Offline

 

#4 2013-01-11 19:28:11

deerprince
New Scratcher
Registered: 2013-01-11
Posts: 2

Re: Collecting items?

Thank you both! I tried it out and it works fine for my game.

Offline

 

#5 2013-01-11 19:31:04

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: Collecting items?

deerprince wrote:

Thank you both! I tried it out and it works fine for my game.

Happy to Help  smile


http://i46.tinypic.com/ao03lk.png

Offline

 

#6 2013-01-12 11:07:46

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: Collecting items?

deerprince wrote:

Thank you both! I tried it out and it works fine for my game.

Your welcome!


http://i46.tinypic.com/35ismmc.png

Offline

 

Board footer