I got two world. I have objects with the class "container" in the world "Terrein" if you touch them you'll enter the other world "InsideContainer". In this world you have a object that returns you to Terrein. But when i return i like the object with the class "container" replaced with another actor how to i do that. I have this so far.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Container here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Container extends Actor
{
/**
* Act - do whatever the Container wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
touchContainer();
}
public void touchContainer()
{
Actor agent = getOneIntersectingObject(Agent.class);
if(agent != null)
{
Greenfoot.setWorld(new InsideContainer());
GecheckteContainer container = new GecheckteContainer();
getWorld().addObject(container,getX(),getY());
}
}
}
