public void act() { if (Greenfoot.isKeyDown("escape")) { if (getWorld().getObjects(pauseMenu.class).isEmpty() ) { getWorld().addObject(new pauseMenu(), 300, 300); getWorld().addObject(new ingameExitButton(), 304, 428); } else { while (!Greenfoot.isKeyDown("r")) { timeDelay(1); Actor actor = getOneIntersectingObject(pauseMenu.class); getWorld().removeObject(actor); Actor eBut = getOneIntersectingObject(ingameExitButton.class); getWorld().removeObject(eBut); } } } animation(); testeTasteGedrueckt(); suchUndEss(); }
public class ingameExitButton extends pauseMenu { private static final GreenfootImage transpar = new GreenfootImage("transpar.png"); public void act() { transpar.scale(44, 17); ExitButton(); setImage("crab.png"); }/* (World, Actor, GreenfootImage, Greenfoot and MouseInfo)*/ /** * Constructor for objects of class playButton. */ public void ExitButton() { if (Greenfoot.mouseClicked(this)) { Greenfoot.setWorld(new MainMenu()); } } }