Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make something detect if mouse pointer is at the left or right?
- 95045290
-
Scratcher
70 posts
How do I make something detect if mouse pointer is at the left or right?
How do I make something detect if mouse pointer is at the left or right? Tell me if you know.
Topic is already answered.
Topic is already answered.
Last edited by 95045290 (July 17, 2020 17:23:44)
- zahmbie1
-
Scratcher
1000+ posts
How do I make something detect if mouse pointer is at the left or right?
Welp, here you go
when green flag clickedsame with the Mouse Y
forever
if <(mouse x) > [Number that has no -]> then
whatever
end
if < (mouse x) < [Number that has a -]> then
whatever
end
end
- Byron_Inc
-
Scratcher
1000+ posts
How do I make something detect if mouse pointer is at the left or right?
There's a mouse x and mouse y reporter block at the sensing category.

when I receive [detect v]I hope it helps you.
if <(mouse x) > (0)> then
right script :: grey stack
else
left script :: grey stack
end

Last edited by Byron_Inc (July 13, 2020 01:06:20)
- 95045290
-
Scratcher
70 posts
How do I make something detect if mouse pointer is at the left or right?
But it needs to detect if mouse is at the right or left of where it is pointing at.
- ScratchCatHELLO
-
Scratcher
1000+ posts
How do I make something detect if mouse pointer is at the left or right?
But it needs to detect if mouse is at the right or left of where it is pointing at.Both of those scripts do that
- Cutie_Pooge
-
Scratcher
500+ posts
How do I make something detect if mouse pointer is at the left or right?
set [myDirection v] to (direction)
point towards [mouse-pointer v]
set [mouseDirection v] to [middle]
if <(direction) > (myDirection)> then
set [mouseDirection v] to [right]
end
if <(direction) < (myDirection)> then
set [mouseDirection v] to [left]
end
point in direction (myDirection)
- 95045290
-
Scratcher
70 posts
How do I make something detect if mouse pointer is at the left or right?
doesn't workset [myDirection v] to (direction)
point towards [mouse-pointer v]
set [mouseDirection v] to [middle]
if <(direction) > (myDirection)> then
set [mouseDirection v] to [right]
end
if <(direction) < (myDirection)> then
set [mouseDirection v] to [left]
end
point in direction (myDirection)
- Cutie_Pooge
-
Scratcher
500+ posts
How do I make something detect if mouse pointer is at the left or right?
Oh yeah, that's because scratch direction goes from 0 to 90 to 180 to -90 to 0. I'll try to fix it.
- Cutie_Pooge
-
Scratcher
500+ posts
How do I make something detect if mouse pointer is at the left or right?
- 95045290
-
Scratcher
70 posts
How do I make something detect if mouse pointer is at the left or right?
Here: https://scratch.mit.edu/projects/411234326/It's to confusing.
- HridayTheCreator
-
Scratcher
100+ posts
How do I make something detect if mouse pointer is at the left or right?
How do I make something detect if mouse pointer is at the left or right? Tell me if you know.
Here you go:
when green flag clicked
if <(mouse x) < (y position)> then
left script:: grey
else
right script:: grey
end
- Cutie_Pooge
-
Scratcher
500+ posts
How do I make something detect if mouse pointer is at the left or right?
It's the easiest way I could find.Here: https://scratch.mit.edu/projects/411234326/It's to confusing.
- Oumuamua
-
Scratcher
1000+ posts
How do I make something detect if mouse pointer is at the left or right?
How do I make something detect if mouse pointer is at the left or right? Tell me if you know.
I´m not quite sure of understanding you. May be https://scratch.mit.edu/projects/411501837/ ?
Last edited by Oumuamua (July 14, 2020 17:05:56)
- Cutie_Pooge
-
Scratcher
500+ posts
How do I make something detect if mouse pointer is at the left or right?
I´m not quite sure of understanding you. May be https://scratch.mit.edu/projects/411501837/ ?That only accounts for when the sprite is at (0, 0). Also, the sprite is a bit off centre and looks weird.
- Oumuamua
-
Scratcher
1000+ posts
How do I make something detect if mouse pointer is at the left or right?
I´m not quite sure of understanding you. May be https://scratch.mit.edu/projects/411501837/ ?That only accounts for when the sprite is at (0, 0). Also, the sprite is a bit off centre and looks weird.
Well, i have not idea if it is at screen´s center, about being off centre, who cares? it is simple to fix.
- HepticSupport
-
New Scratcher
9 posts
How do I make something detect if mouse pointer is at the left or right?
when green flag clickedend
forever
if <<(mouse x) > (x)>> then
(do whatever)
end
define x
set x to (x)
Last edited by HepticSupport (July 14, 2020 13:35:02)
- 95045290
-
Scratcher
70 posts
How do I make something detect if mouse pointer is at the left or right?
Can you make the line start at the middle?It's the easiest way I could find.Here: https://scratch.mit.edu/projects/411234326/It's to confusing.
- Cutie_Pooge
-
Scratcher
500+ posts
How do I make something detect if mouse pointer is at the left or right?
Just place the purple dot at the centre, if your project always has the starting at the centre you can just use Oumuamua's script.
- 95045290
-
Scratcher
70 posts
How do I make something detect if mouse pointer is at the left or right?
Thanks everyone, but I actually figured out how to do it myself.
- Oumuamua
-
Scratcher
1000+ posts
How do I make something detect if mouse pointer is at the left or right?
Thanks everyone, but I actually figured out how to do it myself.

Please shre your solution, it will help others scrtachers some day. Thanks.
My last attempt:
https://scratch.mit.edu/projects/411701816/
- Discussion Forums
- » Help with Scripts
-
» How do I make something detect if mouse pointer is at the left or right?