I've been implementing Loading Screens in my game for the purpose of loading another world and unloading the previous but I'm stuck to unloading each and every individual object in the previous world, here is my code so far -
If anyone knows how to unload an entire world, I'd appreciate it.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Loading here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Loading extends World
{
private int timer = 300;
/**
* Constructor for objects of class Loading.
*
*/
public Loading()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(800, 464, 1);
prepare();
}
public void act()
{
if (timer>0)
{
timer--;
if(timer == 0) Greenfoot.setWorld(new Menu());
}
}
/**
* Prepare the world for the start of the program.
* That is: create the initial objects and add them to the world.
*/
private void prepare()
{
LoadingText loadingtext = new LoadingText();
addObject(loadingtext,413,231);
}
}
