Sorry if I am getting annoying but im really stuck here.
I wanted to switch worldsif two actors are touching each other.
Heres what I have.
Thats the new world that I want my world to set to.
Thank you!!
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MyWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MyWorld extends World
{
private Counter scoreCounter;
public static boolean finish= false;
/**
* Constructor for objects of class MyWorld.
*
*/
public MyWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1200, 700, 1);
popWorld();
gameOver();
}
public void popWorld()
{
//Shark
addObject( new Shark(), 50, 40);
addObject( new Shark2(), 51, 673);
//Minnow
addObject( new Minnow(), 573, 60);
//Checkpoint
addObject( new Checkpoint(), 1173,338);
//TitleScreen
addObject( new TitleScreen2(), 646,383);
//Counter
addObject( new Counter(), 1161,26);
//Wall
addObject( new Wall(), 228,339);
addObject( new Wall(), 908,339);
}
public void gameOver()
{
Actor a = (Actor) getObjects(Shark.class).get(0);
if (a != null)
{
if (finish==true)
{
Greenfoot.setWorld(new NewWorld());
}
}
//Super_Hippo
//Sent the new world
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class NewWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class NewWorld extends World
{
/**
* Constructor for objects of class NewWorld.
*
*/
public NewWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(600, 400, 1);
Worldpop();
}
public void Worldpop()
{
//Obstacle
addObject( new Obstacle(), 730,486);
addObject( new Obstacle(), 857,593);
addObject( new Obstacle(), 990,484);
addObject( new Obstacle(), 749,143);
addObject( new Obstacle(), 881,273);
addObject( new Obstacle(), 1010,140);
}
}
