Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » mousepointer detection with clones
- squelz
-
Scratcher
100+ posts
mousepointer detection with clones
https://scratch.mit.edu/projects/1378590790/
ISSUE: i have three clones and one varible not related to any sprites, i want to be able to hover ANY clone and make the variable say 1, and when im not hovering over ANY of them itll be 0
the variable is “selection:IsHovering?”
ISSUE: i have three clones and one varible not related to any sprites, i want to be able to hover ANY clone and make the variable say 1, and when im not hovering over ANY of them itll be 0
the variable is “selection:IsHovering?”
when I start as a clone
forever
if <touching [mouse pointer v] ?> then
set [selection:IsHovering v] to [1]
else
set [selection:IsHovering v] to [0]
end
end
Last edited by squelz (Sept. 7, 2026 03:37:39)
- 102acrimea
-
Scratcher
100+ posts
mousepointer detection with clones
Ensure selection:IsHovering is for all sprites and not for this sprite only
when green flag clicked
forever
set [selection:IsHovering v] to [0]
broadcast [check v] and wait
end
when I receive [check v]
if <touching [mouse pointer v] ?> then
set [selection:IsHovering v] to [1]
end
- 10goto10
-
Scratcher
1000+ posts
mousepointer detection with clones
I suppose it's possible that in general the mouse could touch more than one clone. I made something that works. There might be easier ways to do this but here is my case study:
https://scratch.mit.edu/projects/1378684024/
Another thing I tried to do was avoid having the sprite itself report touching the mouse pointer because a hidden sprite will still detect touching the mouse. I don't think this matters in your project because the sprite overlaps your third clone, but it's something I wanted to avoid.
https://scratch.mit.edu/projects/1378684024/
Another thing I tried to do was avoid having the sprite itself report touching the mouse pointer because a hidden sprite will still detect touching the mouse. I don't think this matters in your project because the sprite overlaps your third clone, but it's something I wanted to avoid.
Last edited by 10goto10 (Sept. 7, 2026 04:38:31)
- supadupa_cutecat
-
Scratcher
32 posts
mousepointer detection with clones
Personally what i would do (so it checks both instead of one
when I start as a clone
forever
if <touching [... v] ?> then
set [text v] to [1]
else
if <not <touching [... v] ?>> then
set [text.. v] to [0]
end
end
end
Last edited by supadupa_cutecat (Sept. 7, 2026 04:54:03)
- follower_Guy7
-
Scratcher
7 posts
mousepointer detection with clones
please go and check out my project it is so good https://scratch.mit.edu/projects/1375132648
- squelz
-
Scratcher
100+ posts
mousepointer detection with clones
Personally what i would do (so it checks both instead of onewhen I start as a clone
forever
if <touching [... v] ?> then
set [text v] to [1]
else
if <not <touching [... v] ?>> then
set [text.. v] to [0]
end
end
end
ok so this is the same problem as just setting the variable back to 0 though???? the “if then else” is already the “false” output, theres really no need to add another layer of “if not touching” ill try out the other solutions
Last edited by squelz (Sept. 7, 2026 13:15:34)
- squelz
-
Scratcher
100+ posts
mousepointer detection with clones
please go and check out my project it is so good https://scratch.mit.edu/projects/1375132648
please dont advertise your project here
- squelz
-
Scratcher
100+ posts
mousepointer detection with clones
Ensure selection:IsHovering is for all sprites and not for this sprite onlywhen green flag clicked
forever
set [selection:IsHovering v] to [0]
broadcast [check v] and wait
end
when I receive [check v]
if <touching [mouse pointer v] ?> then
set [selection:IsHovering v] to [1]
end
this like 50/50 works but with the “description” feature im trying to add this would just make it flash

- squelz
-
Scratcher
100+ posts
mousepointer detection with clones
I suppose it's possible that in general the mouse could touch more than one clone. I made something that works. There might be easier ways to do this but here is my case study:
https://scratch.mit.edu/projects/1378684024/
Another thing I tried to do was avoid having the sprite itself report touching the mouse pointer because a hidden sprite will still detect touching the mouse. I don't think this matters in your project because the sprite overlaps your third clone, but it's something I wanted to avoid.
ok yeah wow, this just works flawlessly
- Discussion Forums
- » Help with Scripts
-
» mousepointer detection with clones