I'd appreciate if there was a method to check if code is being simulated because I use some JOptionPane's and it is weird when they randomly pop up because their code was simulated.
at Button.act(Button.java:50) at greenfoot.core.Simulation.actActor(Simulation.java:594) at greenfoot.core.Simulation.runOneLoop(Simulation.java:552) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205)
public void act()
{
if(Greenfoot.mouseClicked(this))
{
switch(type)
{
case "teacup": type = "teancodetext"; setPicture(); break;
case "teancodetext": type = "teacup"; setPicture(); break;
case "world": Greenfoot.setWorld(world); break;
case "back": Greenfoot.setWorld(world); break;
case "help": Greenfoot.setWorld(new HelpWorld(world)); break;
case "newgame": Greenfoot.setWorld(new HubWorld(false));
case "continuegame": Greenfoot.setWorld(new HubWorld(true));
case "save": Save.saveWarn(Save.prepareString(),"Save.sav");
}
}
}static void saveWarn(String toWrite, String path)
{
int response = JOptionPane.showConfirmDialog(null,"Warning: Saving will overwrite the current save. Continue?");
if(response == JOptionPane.OK_OPTION)
writeSave(toWrite,path);
}