Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a sprite do something when it's clicked
- hawk9510
-
Scratcher
64 posts
How to make a sprite do something when it's clicked
Please help!
when green flag clickedWill not work!!
if <<touching [mouse pointer v] ?> and <<mouse down?> >> then
say [You clicked me!] for (2) secs
end
Last edited by hawk9510 (Dec. 30, 2014 00:08:17)
- shoresbeep
-
Scratcher
1000+ posts
How to make a sprite do something when it's clicked
when this sprite clicked
- digthebone
-
Scratcher
500+ posts
How to make a sprite do something when it's clicked
make sure to add a forever there or it will just give you like a millisecond to click it.
when green flag clicked
forever
if <<touching [mouse pointer v] ?> and <mouse down?> > then
say [You clicked me!] for (2) secs
end
end
Last edited by digthebone (Dec. 31, 2014 20:40:18)
- hawk9510
-
Scratcher
64 posts
How to make a sprite do something when it's clicked
when this sprite clicked
???
- Iri-O
-
Scratcher
100+ posts
How to make a sprite do something when it's clicked
I believe that shoresbeep was saying that thewhen this sprite clicked
???
when this sprite clickedblock will help.
- shoresbeep
-
Scratcher
1000+ posts
How to make a sprite do something when it's clicked
Yes, exactlyI believe that shoresbeep was saying that thewhen this sprite clicked
???when this sprite clickedblock will help.

- Crimson19
-
Scratcher
1000+ posts
How to make a sprite do something when it's clicked
Its simply:
when this sprite clicked
Whatever happens after the sprite is clicked.
- Portaldominates
-
Scratcher
8 posts
How to make a sprite do something when it's clicked
when this sprite clicked
Use this sprite and put anything you want it to do under it.
- Leto42407
-
Scratcher
100+ posts
How to make a sprite do something when it's clicked
You Did It All Wrong You Said When Green Flag Clicked Instead Of When THIS SPRITE Clicked
when this sprite clickedSee How It Goes Now?
forever
if <<touching [Mouse Pionter v] ?> and <<mouse down?> >> then
say [You Clicked Me!] for (5) secs
end
- iamunknown2
-
Scratcher
1000+ posts
How to make a sprite do something when it's clicked
Please help!I had the same problem a long time ago, when people were still using 1.4. If I remember correctly, I spent hours figuring out that problem.when green flag clickedWill not work!!
if <<touching [mouse pointer v] ?> and <<mouse down?> >> then
say [You clicked me!] for (2) secs
end
The solution is:
You aren't putting the forever block there.
You see, Scratch perceives your code as this:
So, there will be one block of (really short) time to click the button. Or else, nothing will happen and the program will come to a stop.If you put a “forever” block, Scratch will check if you've clicked that button OVER AND OVER again. That is, unless you stop it.
However, if you tried to increase the variable by 1 every time that happened, it would hit a thousand under a second, because Scratch thinks like this:
So, in this (tiny) block of time, let's see if the mouse has clicked us. Yes? Oh well. VARIABLE! I COMMAND YOU TO CHANGE BY ONE! (tiny block of time is over) OK. let's check again. It's true? VARIABLE, CHANGE YOUR VALUE BY ONE AGAIN! …So, you would want a “wait until” block that would only allow your “forever” loop to continue, unless you released the mouse-button:
wait until <not <mouse down?>>
- hawk9510
-
Scratcher
64 posts
How to make a sprite do something when it's clicked
Oh.I believe that shoresbeep was saying that thewhen this sprite clicked
???when this sprite clickedblock will help.
- Food_Is_Bae
-
Scratcher
3 posts
How to make a sprite do something when it's clicked
In one of my projects, a sprite must be clicked a certain amount of times before it dissapears. How do I tell Scratch to wait until this sprite has been clicked say, five times?
- deck26
-
Scratcher
1000+ posts
How to make a sprite do something when it's clicked
In one of my projects, a sprite must be clicked a certain amount of times before it dissapears. How do I tell Scratch to wait until this sprite has been clicked say, five times?Please start your own topic rather than necroposting. The New Topic button is at the top right of the forum.
- streamline1
-
Scratcher
79 posts
How to make a sprite do something when it's clicked
Your old script is just fine. All you have to do is put a forever loop around it. If you don't, when you execute the code, it will run the if loop and stop.
- rajauppal
-
Scratcher
17 posts
How to make a sprite do something when it's clicked
when this sprite clicked
say [you clicked me!] for (2) secs
- cs293450
-
Scratcher
100+ posts
How to make a sprite do something when it's clicked
Please help!Yes it does…when green flag clickedWill not work!!
if <<touching [mouse pointer v] ?> and <<mouse down?> >> then
say [You clicked me!] for (2) secs
end
when this sprite clicked
say [You clicked me!] for (2) secs
- Discussion Forums
- » Help with Scripts
-
» How to make a sprite do something when it's clicked