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

#1 2008-04-08 21:20:30

Drawsher
Scratcher
Registered: 2008-04-08
Posts: 1

a question on the controls

OK, so my question is how do you program the
                                                       <when I receive[     button?
Can someone direct me to any really helpful pages of how to program that botton?

I want it so that when the score gets to sa certain amount it goes to the ending page...

Last edited by Drawsher (2008-04-08 21:29:03)

Offline

 

#2 2008-04-08 22:58:48

Donut-slayer
Scratcher
Registered: 2008-04-08
Posts: 13

Re: a question on the controls

OK first make a variable called score/points...or what ever, then have whenever you make a score(in a sports game or killing a monster or whatever) broadcast, I made score(or whatever) then put on the same character, the one your using, when I receive "I made score",or whatever you named it, put "change score by 1(or whatever you want the score to change by)" Then put a "forever if" and on top of that "equals sign thing" then on top of that put your score variable and however much you want it to equal for winning the game in the spot beside it and below that put "broadcast, win game or whatever " then go to your stage thing and put "WHEN I RECIEVE,win game(or whatever) change background to...(whatever your winning background is) and makesure
that when the other characters recieve "win game or whatever" they "hide" so they dont get in the way of the background  big_smile

Offline

 

#3 2008-04-09 01:06:42

MasterOfMac
Scratcher
Registered: 2008-02-01
Posts: 62

Re: a question on the controls

Donut-slayer: You are thinking of the variable function.

The "When I recieve" block is useful for sending commands between sprites. This block is activated when another block sends (Or "Broadcasts") a message. Lets say that you wanted a square to change color whenever a certain sprite collides with it... You would put the following blocks into the moving sprite (After implementing keyboard movement commands...)
-[blocks]
<when green flag clicked>
<forever>
<if><touching[ Square
<broadcast[ colorchange
[/blocks]

Now you have the signal set up.
Next, switch over to the sprite called "Square"
and put in the following blocks:

[blocks]
<when I receive[ colorchange
<set[ Color ]effect to( <pick random( 0 )to( 150
[/blocks]

That should work.
If you just want to test the code without making the sprite move with the keyboard, just drag in (On the stage) into the square sprite. Remember; the green flag MUST be activated for this script to work!

Last edited by MasterOfMac (2008-04-09 01:13:02)


*sarcasm*

Offline

 

Board footer