Hy! I created a world with some peoples and an elevator,I want to make the people to go to the elevator and when this happens the world should change,how is it possible!
public class person
{
public void act()
{
if(getOneIntersectingObject(elevator.class) != null)
{
setWorld(name of your new world)
}
else
{
move(1);
}
}
}private boolean turnedToElevator = false;
public void act() {
if (!turnedToElevator) {
turnTowards(elevatorX, elevatorY);//of course the coordinates of the elevator have to be known.
turnedToElevator = true;
}
move();
if (getOneIntersectingObject(Elevator.class) != null) {
getWorld().removeObject(this);
}
}public void act() {
if (getObjects(People.class).isEmpty()) {
Greenfoot.setWorld(new World2());
}
}public void act() {
if (getObjects(People.class).isEmpty()) {
Greenfoot.setWorld(new Wall());
}
} import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class florin2 here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Florin2 extends Actor
{
private boolean turnedToLift=false;
private Lift lift;
/**
* florin2 turns towards an Lift, moves to it and removes itself after touching one
*/
public void act()
{
if(lift==null)
{
getLift();
}
if (!turnedToLift)
{
turnTowards(lift.getX(),lift.getY());
turnedToLift = true;
}
move(1);
if (getOneIntersectingObject(Lift.class) != null)
{
getWorld().removeObject(this);
}
}
private void getLift()
{
List<Lift> LiftList = getObjects(Lift.class);
if(!LiftList.isEmpty())
{
lift = LiftList.get(0)
}
}
}