Discuss Scratch

bn69031
New Scratcher
2 posts

How do I make a sprite appear after certain sprites are clicked?

Like, let's say I have five sprites. I want a sixth sprite to appear but only if all five sprites are clicked. It doesn't matter if the order is different or how long it takes to click on one and then the other. Please help me! Thanks!

Last edited by bn69031 (Dec. 31, 2015 23:37:10)

awesome-llama
Scratcher
1000+ posts

How do I make a sprite appear after certain sprites are clicked?

You can have variables for each sprite, and the 6th sprite will only apppear if the variables are all set to true. Each sprite, when clicked, set their variable to true.
Or, you can replace it with a list for more efficiency.
when this sprite clicked
replace item (sprite no. v) of [ clicked v] with [true]
// do this with all sprites needed to be clicked. Just change the sprite number from 1 to 5.
forever

if <all of list is true> then // I'm too lazy to write the script part item 1 of list = true and item 2 of .......
6th sprite shows.
end

end
footsocktoe
Scratcher
1000+ posts

How do I make a sprite appear after certain sprites are clicked?

Another way would be with two variables, a global variable called TOTAL and local variables for each of the five sprites called CLICKED?

Green flag for each sprite sets its CLICKED? to false.

Hat block “When this sprite clicked” for each of the five sprites has following

If CLICKED? = false then
Change TOTAL by 1
Set CLICKED? to true


In the 6th sprite's Green Flag script put
Hide
Set TOTAL = 0
Wait until TOTAL = 5
Show

Last edited by footsocktoe (Jan. 1, 2016 00:49:23)

imbradley999
Scratcher
90 posts

How do I make a sprite appear after certain sprites are clicked?

when this sprite clicked
broadcast [what you name it v]
when I receive [ v]
show
UndeadSorcerer
Scratcher
100+ posts

How do I make a sprite appear after certain sprites are clicked?

First 5 sprites
when green flag clicked
set [click v] to [0 ]
forever

if <mouse down?> then
if <touching [mouse pointer v] ?> then
change [click v] by (1)
stop [this script v]
end

end

end

6th
when green flag clicked
wait until <[5] < (click)>
show
moss-shadow
Scratcher
500+ posts

How do I make a sprite appear after certain sprites are clicked?

If you click one item to make another disappear, make one sprite:
when this sprite clicked
broadcast [ v]

If you click multiple items to make one disappear, create a variable that turns into 0 at the start:
when green flag clicked
set [ v] to [0 ]

Then do this to each sprite that will be clicked:
when this sprite clicked
change [ v] by (1)

And do this to the sprite that will disappear:
when green flag clicked
forever

if <[(Variable)] = [(Number of sprites you need to click) ]> then
hide

end
Daphne_456456-Minec
Scratcher
100+ posts

How do I make a sprite appear after certain sprites are clicked?

How to do it:

Way 1:

You can put this script anywhere:

when green flag clicked
set [whatever variable you want this to be v] to [0]

And in each of the 5 sprites:

when this sprite clicked
change [whatever variable you want this to be v] by (1)

And in the sixth:

when green flag clicked
hide
forever
if <(whatever variable you want this to be) = [5]> then
show
broadcast [I dunno v]
stop [this script v]
end
end

You can take away the broadcast if you just want it to be text or that sort of stuff.


Way 2:

Put this anywhere:

when green flag clicked
delete (all v) of [your list v]

And in each of the 5 sprites:

when this sprite clicked
add [whatever you want] to [list v]

And in the 6th sprite:

when green flag clicked
hide
forever
if <<<[list v] contains [bla]> and <[list v] contains [bla]>> and <<[list v] contains [bla]> and <<[list v] contains [bla]> and <[list v] contains [bla]>>>> then
show
broadcast [whatever v]
stop [this script v]
end

end

Sorry for the cut-off at the “if _____ then” block. (It just says the same thing as the others.)

Each sprite should add a different thing to the list. For example, one should be “bla” and another can't also be “bla”, it has to be something else like “random”. If they add the same thing, I'm pretty sure the project will go crazy.

Of course, you an replace the hide block with this:

set [ghost v] effect to (100)

or…

change [ghost v] effect by (100)

And to replace the show blocks, for the top example of this, “set ghost effect to 0”, and for the bottom example, “change ghost effect by -100”.

But remember, for ghost effect, if you press the red stop sign, it will show completely at “set ghost effect to 0” regardless of what code is running unless you've also included a “hide” block.

For both examples, you can take out the “stop all” block, but then the script will keep on running unless somewhere you put…

stop [all v]

…and the script with that block runs.

Last edited by Daphne_456456-Minec (Jan. 1, 2016 02:37:40)

bn69031
New Scratcher
2 posts

How do I make a sprite appear after certain sprites are clicked?

It seems like all the ways I received don't work. Could you guys look at my script for me to see what I did wrong?

https://scratch.mit.edu/projects/88487493/#player
footsocktoe
Scratcher
1000+ posts

How do I make a sprite appear after certain sprites are clicked?

There is no sprite that adds “click 5” to the list.
s11803731
Scratcher
31 posts

How do I make a sprite appear after certain sprites are clicked?

Put this script in each 5 sprites:
when this sprite clicked
change [Clicked Sprite?] by (1)


And then, put this script into one of the sprites:
when green flag clicked
if <(Clicked Sprite?) = [5]> then
broadcast [5 Sprite]
end

Finally, put this into the sixth:


when I receive [5 Sprite]
show
deck26
Scratcher
1000+ posts

How do I make a sprite appear after certain sprites are clicked?

s11803731 wrote:

Put this script in each 5 sprites:
when this sprite clicked
change [Clicked Sprite?] by (1)


And then, put this script into one of the sprites:
when green flag clicked
if <(Clicked Sprite?) = [5]> then
broadcast [5 Sprite]
end

Finally, put this into the sixth:


when I receive [5 Sprite]
show
Please check the date before posting, this topic is old and should be left to sleep quietly.
SimplyKomplex
Scratcher
100+ posts

How do I make a sprite appear after certain sprites are clicked?

simple, on the clicked sprite:
when this sprite clicked
broadcast [clicked v]
and on the other sprite:
when I receive [clicked v]
show
deck26
Scratcher
1000+ posts

How do I make a sprite appear after certain sprites are clicked?

SimplyKomplex wrote:

simple, on the clicked sprite:
when this sprite clicked
broadcast [clicked v]
and on the other sprite:
when I receive [clicked v]
show
Please read the topic and note the date before posting - your ‘help’ doesn't address the issue and the topic is old.
TGOTK
New Scratcher
1 post

How do I make a sprite appear after certain sprites are clicked?

Hi I am trying to make a sound play when one sprite is clicked but a different sound when 2 sprites are clicked.

Powered by DjangoBB