Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » [RESOLVED] "when this sprite clicked" block
- NamePending_
-
Scratcher
100+ posts
[RESOLVED] "when this sprite clicked" block
In many popular projects, I have seen that the creator didn't use the “when this sprite clicked” block, instead doing something like this:
foreverDoes anyone know why this is the case?
if <touching [mouse-pointer v] ?> then
...
wait until <not<touching [mousepointer v] ?>>
end
end
Last edited by NamePending_ (April 3, 2024 21:24:00)
- SpyCoderX
-
Scratcher
1000+ posts
[RESOLVED] "when this sprite clicked" block
In many popular projects, I have seen that the creator didn't use the “when this sprite clicked” block, instead doing something like this:They have 2 different functions…foreverDoes anyone know why this is the case?
if <touching [mouse-pointer v] ?> then
...
wait until <not<touching [mousepointer v] ?>>
end
end
> “When this sprite clicked” only runs when this sprite is clicked
> Your example only runs if it is touching the mouse, and only runs the code once (until you move the mouse off the sprite / clone, and then you can run the code again).
If you meant about “touching mouse-pointer and mousedown” then…
> “When this sprite clicked” works for the sprite and its clones.
> Your example can be for only a clone or only the sprite itself.
It could also just be a person preference. Some people like using a forever loop instead of a hat block for certain things.
Note: I don't know everything, so I probably missed something.
Hope this helps!
- deck26
-
Scratcher
1000+ posts
[RESOLVED] "when this sprite clicked" block
Touching the mouse-pointer is not the same as being clicked. That code may just be used to detect the mouse hovering over a button, for example.
- BigNate469
-
Scratcher
1000+ posts
[RESOLVED] "when this sprite clicked" block
As someone who stopped using the “when sprite clicked” hat block long ago for most everything, I've found puting the listener inside a loop makes it easier to tell when a sprite is clicked. Also why you don't use more than one forever loop if you can help it- everything happens in a sequence anyways, and there isn't a point in intentionally making it so that you don't know that sequence.
- Discussion Forums
- » Help with Scripts
-
» [RESOLVED] "when this sprite clicked" block



