How can I see if mouse has clicked on a certain area (coordinates with if statement)?
I don't mean clicking on actors, I mean just an area on the screen. I would also like to do this in the World class.


1 2 3 4 5 6 7 8 9 10 | MouseInfo mouse = Greenfoot.getMouseInfo(); if (mouse != null ) { int x = mouse.getX(); int y = mouse.getY(); } if (Greenfoot.mouseClicked( null )) { if (x > minX && x < maxX && y > minY && y < maxY) { //min and max should be the edges of the area; //whatever you want to do if the area is clicked; } } |