Can someone send mainmenu code to me?
Please
public class MainMenu extends Actor { private MouseInfo mouse; public void act() { mouse = Greenfoot.getMouseInfo(); if (Greenfoot.mouseClicked(this) && mouse != null) { if (mouse.getX() > startX1 && mouse.getX() < startX2 && mouse.getY() > startY1 && mouse.getY() < startY2) { //instead of startX/Y you have to use the coordinates of the buttons; //X1 is the left x coordinate of the button, X2 is the right, Y1 is the top y coordinate and Y2 the bottom y coordinate; //start the game; } if (mouse.getX() > instrX1 && mouse.getX() < instrX2 && mouse.getY() > instrY1 && mouse.getY() < instrY2) { getWorld().addObject(new Instruction(), getWorld().getWidth()/2, getWorld().getWidth()/2); //the instructions also should have a button to return to the main menu. Therefore you can use the same code as in this class. } } } }
//... if (Greenfoot.mouseClicked(this) && mouse != null) { //... System.out.println(mouse.getX() + " " + mouse.getY()); //this will show the current mouse coordinates when you click on the main menu image. }