How do I check if the cursor is between 2 specific angles

Get help using Construct 2

Post » Tue Jul 21, 2015 1:47 pm

Hey guys,

I was playing around again with Construct 2 and was wondering whether or not i can check if the cursor is between 2 specific angles of an object. For example the mouse being between 70 and 110 degrees of a player or it being -20 en 20 degrees etc.

Thanks in advance
B
4
Posts: 11
Reputation: 222

Post » Tue Jul 21, 2015 2:46 pm

Yes you can, What I did was set up a sprite set it's angle towards my mouse X and Y. Then I used the "is between angles" of that sprite to find what angle my mouse is at on the screen.
B
29
S
6
G
1
Posts: 93
Reputation: 3,020

Post » Tue Jul 21, 2015 2:50 pm

Thanks! I was thinking about this but did not test this yet. Thanks a lot!
B
4
Posts: 11
Reputation: 222

Post » Tue Jul 21, 2015 3:34 pm

You can use the expression:

angle(object.x,object.y,mouse.x,mouse.y)

to get the angle between the object and the mouse

So something like this should work:
system is between angles : angle(object.x,object.y,mouse.x,mouse.y) ; object.angle-20 ; object.angle+20
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Microbex, totoe and 18 guests