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

#1 2008-01-13 10:50:50

messd002
Scratcher
Registered: 2007-12-07
Posts: 100+

How to make a 'showing' block.

Note. If I am incorrect please tell me, and if possible post your own suggestions. I am pretty sure this works.

I wouldn't be suprised if there a some scratchers who have thought of this, but for those who havn't...

Lets say we wanted the 'dog' sprite to play sound woof when the 'cat' sprite is showing. You will have to press space to show the cat:

You will need one variable called 'cat showing'.
[blocks]

On the 'cat' sprite place this script:
<when green flag clicked>
<hide>
<set{ cat showing }to( 0

By setting 'cat showing' to 0 it is saying that the cat isn't showing.

<when[ Space ]key pressed>
<show>
<set{ cat showing }to( 1

This script says that when the space key is pressed the cat will show, and set cat showing to 1, which means that the cat is showing. The following script is for the 'dog' sprite.

<when green flag clicked>
<forever>
<if><( <{ cat showing }> <=> 1 )>
<play sound[ woof
<end>
<end>

This is saying that when cat showing is equal to 1 (in other words the cat sprite is showing) the dog will play sound woof.

Ps. I know this example project could be done with broadcasting, but I am sure there are occassions where it cannot. Remember, if there are any errors (probably are knowing me  wink ) please tell me.


Burn baby Burn!

Offline

 

Board footer