Hello everyone. I am trying to create a very basic button and i use Greenfoot.getMouseInfo() function to... be able to compare if the cursor is "above" the button. The problem is.. it was always returning null..and i don t know how to change that. Here is the code:
I would want to use what Greenfoot offers..but if i can't find a sollution..i guess i'll use MouseListener
MouseInfo mouse = Greenfoot.getMouseInfo();
public void act()
{
MENU(world);
if (mouse != null){
mouseinput(mouse, wStart);
}
}
public void mouseinput(MouseInfo m, World w){
if (mousePressed(m, world.getWidth()/2 - 128, 100, 200, 100)){
bg.running = true;
}
}
public boolean mousePressed(MouseInfo m, int x, int y, int width, int height){
if (Greenfoot.mouseClicked(world)){
if(m.getX()>x && m.getX()<x+width){
if (m.getY()>y && m.getY()<y+height){
return true;
}
}
}
return false;
}

