This site requires JavaScript, please enable it in your browser!
Greenfoot back
Gazzzah
Gazzzah wrote ...

2011/12/19

Left and Right click booleans

Gazzzah Gazzzah

2011/12/19

#
Hi I need to write a simple method that uses two booleans, "leftClicked" and "rightClicked". It's pretty self explanatory but I want leftClicked to be true when the left mouse button is down and "rightClicked" to be true when the right mouse button is down. Anyone know how to achieve this?
Gazzzah Gazzzah

2011/12/19

#
Also, I need a method that gets the angle that points to the mouse, from a certain point (400, 300).
danpost danpost

2011/12/19

#
As far as 'leftClicked' and 'rightClicked', check out the Greenfoot API on MouseInfo. Also, there are five methods within the Greenfoot class that deal with getting info from the mouse. For angle to mouse, use standard trigonometric functions.
Gazzzah Gazzzah

2011/12/19

#
danpost wrote...
As far as 'leftClicked' and 'rightClicked', check out the Greenfoot API on MouseInfo. Also, there are five methods within the Greenfoot class that deal with getting info from the mouse. For angle to mouse, use standard trigonometric functions.
I understand the trigonometry, it would be something like tan^-1(xlength/ylengnth), but how do I write that in greenfoot / java as a method or void.
danpost danpost

2011/12/19

#
Check out the discussion at www.greenfoot.org/topics/220. The basic code for the angle (and distance) is given there.
You need to login to post a reply.