Discuss Scratch

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.

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 clicked
forever
if <(mouse x) > [Number that has no -]> then
whatever
end
if < (mouse x) < [Number that has a -]> then
whatever
end
end
same with the Mouse Y
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]
if <(mouse x) > (0)> then
right script :: grey stack
else
left script :: grey stack
end
I hope it helps you.

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?

95045290 wrote:

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?

Cutie_Pooge wrote:

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)
doesn't work
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?

Cutie_Pooge wrote:

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?

95045290 wrote:

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?

95045290 wrote:

Cutie_Pooge wrote:

Here: https://scratch.mit.edu/projects/411234326/
It's to confusing.
It's the easiest way I could find.
Oumuamua
Scratcher
1000+ posts

How do I make something detect if mouse pointer is at the left or right?

95045290 wrote:

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?

Oumuamua wrote:

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?

Cutie_Pooge wrote:

Oumuamua wrote:

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 clicked
forever
if <<(mouse x) > (x)>> then
(do whatever)
end
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?

Cutie_Pooge wrote:

95045290 wrote:

Cutie_Pooge wrote:

Here: https://scratch.mit.edu/projects/411234326/
It's to confusing.
It's the easiest way I could find.
Can you make the line start at the middle?
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?

95045290 wrote:

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/

Powered by DjangoBB