I am using the Greenfoot.getMouseInfo to keep track of left / right click and mouse location. Problem is, it seems to be that objects only act when the mouse changes e.g if I click or move the mouse. Not cool because my character pivots around the mouse but moves by the keyboard.
How can I make it continually check the mouse info despite it staying constant?
Here is a sample of my code:
1 2 3 4 5 6 7 8 9 | public void findMouse() { if (Greenfoot.getMouseInfo() != null ) { mouseX = Greenfoot.getMouseInfo().getX(); mouseY = Greenfoot.getMouseInfo().getY(); gotoAngle = ( int ) Math.toDegrees(Math.atan2(mouseY - getY(), mouseX - getX())); } } |