Discuss Scratch

lt210
New Scratcher
15 posts

How to make my sprites disappear when clicked

I need to work out how to programme my game, so that when the lady asks for a specific fish, the player will click on the wanted fish, and if it is correct, will disappear. If it is incorrect, it will say ‘try again’. Can anybody help who knows how to programme this?
Thank you
deck26
Scratcher
1000+ posts

How to make my sprites disappear when clicked

Something like this should work

when this sprite clicked
if <[required answer] = [salmon ]> then
hide
else
say [Try again] for (2) secs
end
lt210
New Scratcher
15 posts

How to make my sprites disappear when clicked

Thank you. However, didn't quite work. I need it so the fisherman, says ‘fish 2’ which I have programmed, then if fish 2 is clicked, it should disappear. But at the moment, they are not linking together, and are acting as two separate commands! So confusing!
deck26
Scratcher
1000+ posts

How to make my sprites disappear when clicked

lt210 wrote:

Thank you. However, didn't quite work. I need it so the fisherman, says ‘fish 2’ which I have programmed, then if fish 2 is clicked, it should disappear. But at the moment, they are not linking together, and are acting as two separate commands! So confusing!

So set a variable to what the fisherman says and then use that variable

So for the fisherman
set [ (fishtype)] to [ salmon]
say (join [Get me a ] (fishtype))

and as before for the fish with the if statement being

if <(fishtype) = [salmon ]> then

else

end

Modify this for each fish sprite to reflect the type - or use ‘fish 2’ etc instead of eg ‘salmon’.
hollily
Scratcher
41 posts

How to make my sprites disappear when clicked

when this sprite clicked
hide


this should work

Last edited by hollily (Dec. 12, 2014 16:09:22)

lt210
New Scratcher
15 posts

How to make my sprites disappear when clicked

Thank you so much, I really appreciate your help. Still doesn't seem to work though. I am new to scratch and am finding it so confusing! Is there any way of you being able to see my project so you can see where the issue lies?
If not, thank you anyway for your time.
deck26
Scratcher
1000+ posts

How to make my sprites disappear when clicked

lt210 wrote:

Thank you so much, I really appreciate your help. Still doesn't seem to work though. I am new to scratch and am finding it so confusing! Is there any way of you being able to see my project so you can see where the issue lies?
If not, thank you anyway for your time.
If the project is shared you can cut and paste the URL from your browser and put in your next message. An example of mine - http://scratch.mit.edu/projects/15008960/
deck26
Scratcher
1000+ posts

How to make my sprites disappear when clicked

Here's a simple example of the sort of thing I mean - http://scratch.mit.edu/projects/39424358/

Hopefully that will get you started.
lt210
New Scratcher
15 posts

How to make my sprites disappear when clicked

http://scratch.mit.edu/projects/39524890/

Here is the link to my project. I have tried to copy a similar thing to what you also sent (how did you make it look so easy!) If you can have a look - at fish 1's script and the fisherman in the boat's script and see where i'm going wrong I would be very grateful. I need the fisherman to say e.g. ‘please can i have fish 4, if clicked disappears, if not, ’try again'. Thank you again for your help.
1207769
Scratcher
17 posts

How to make my sprites disappear when clicked

Ok, you need variables for this. First, create a variable, and call it “fish”. It should look something like this:
(fish)
Next, after the fisherman says “Please can i have fish 4”, set that variable to 4. Put this code in the fisherman's sprite:
say [Please can i have fish 4]
set [fish v] to [4]
The codes in each fish will be
when this sprite clicked
if <(fish) = (. . .)> then
hide
end
The
(. . .)
would be the fish number.

Last edited by 1207769 (Dec. 13, 2014 16:31:19)

lt210
New Scratcher
15 posts

How to make my sprites disappear when clicked

Amazing!!!! That worked! Thank you so much. All that needs to happen now is, when the fisherman has asked for the first fish, he needs to ask for the next one. I set it as a broadcast for them, but it keeps skipping straight to the last broadcast rather than going through them one by one and waiting. Any suggestions? I am so so grateful for the help!
1207769
Scratcher
17 posts

How to make my sprites disappear when clicked

EDIT: I saw your project and posted another answer below.

Last edited by 1207769 (Dec. 13, 2014 17:48:56)

1207769
Scratcher
17 posts

How to make my sprites disappear when clicked

Ok, I saw your project, so I changed my code a little to fit your project.

First create the variable
(continue)
Next, every time the correct fish is clicked, set “continue” to 1.
if <(fish) = (. . .)> then
. . .
set [continue v] to [1 ]
end
Now, your broadcasts:
when I receive [#1 v]
. . .
wait until <(continue) = [1 ]>
set [continue v] to [0 ]
broadcast [#2 v]
and repeat…
when I receive [#2 v]
. . .
wait until <(continue) = [1 ]>
set [continue v] to [0 ]
broadcast [#3 v]
and repeat.

Last edited by 1207769 (Dec. 13, 2014 17:50:39)

FrankieJrJr
Scratcher
100+ posts

How to make my sprites disappear when clicked

They are making way to complicated. You have to do this
when green flag clicked
forever
if <<touching [mousepointer] ?> and < <mouse down?>>> then
hide
stop [this script]
FrankieJrJr
Scratcher
100+ posts

How to make my sprites disappear when clicked

Check out the new block
set pen color to (rainbow)

It makes it changes every 0.1 second to a different color in the rainbow.
The_Best_Creator
Scratcher
88 posts

How to make my sprites disappear when clicked

These are all interesting! I like them.
DrIshmael
Scratcher
67 posts

How to make my sprites disappear when clicked

when this sprite clicked
hide
its that simple
lt210
New Scratcher
15 posts

How to make my sprites disappear when clicked

USER: 1207769
I changed the script to how you suggested and I can see how that works. But now, things are repeating and not stopping despite me adding in the ‘stop’ script. I have copied the new link to my project so you can see what I mean if this does not make sense. It also jumps to numbers that are meant to be asked later on! Grr this is so stressful!! Thanks for the help.

Here is the link:

http://scratch.mit.edu/projects/39742832/
deck26
Scratcher
1000+ posts

How to make my sprites disappear when clicked

lt210 wrote:

USER: 1207769
I changed the script to how you suggested and I can see how that works. But now, things are repeating and not stopping despite me adding in the ‘stop’ script. I have copied the new link to my project so you can see what I mean if this does not make sense. It also jumps to numbers that are meant to be asked later on! Grr this is so stressful!! Thanks for the help.

Here is the link:

http://scratch.mit.edu/projects/39742832/
From a quick look you're not setting continue to 0 when you move on to the next fish so the ‘wait until continue=1’ doesn't have much of an effect and the program goes ahead with the next bit. Fix that first and see how far that gets you.
deck26
Scratcher
1000+ posts

How to make my sprites disappear when clicked

You're also broadcasting ‘No 7’ instead of ‘next 7’ in the fisherman2 scripts.

Powered by DjangoBB