The world just shows up as a small box without any images.
Here is my start world class:
import greenfoot.*;
/**
* Write a description of class StartWorld here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class StartWorld extends World
{
/**
* Constructor for objects of class StartWorld.
*
*/
public StartWorld()
{
// Create a new world with 600x400 cells with a cell size of 1x1 pixels.
super(1200, 400, 1);
}
public void act()
{
if (getObjects(startScreen.class).isEmpty()) showStartScreen();
if (getObjects(Kombat.class).isEmpty()) showKombat();
}
public void showStartScreen()
{
addObject(new startScreen(), getWidth() / 2, getHeight() / 2);
}
public void showKombat()
{
addObject(new Kombat(), getWidth() / 2, getHeight() / 4);
}
}
Here is my fight world class:
import greenfoot.*;
import java.awt.Color;
/**
* Write a description of class Crossroads here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Crossroads extends World
{ public BarOne barone = new BarOne("FighterOne", "Health Points", 100, 100);
public BarTwo bartwo = new BarTwo("FighterTwo", "Health Points", 100, 100);
private int FighterOneDeath, FighterTwoDeath;
private int setWorldCounter = 0;
private boolean setWorldTrue = false;
private GreenfootSound music = new GreenfootSound("backgroundOne.mp3");
private GreenfootSound fight = new GreenfootSound("fight.mp3");
private int soundCounterOne = 1;
/**
* Constructor for objects of class Crossroads.
*
*/
public Crossroads()
{
super(1200, 400, 1);
prepare();
}
/**
* Prepare the world for the start of the program. That is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
Road road = new Road();
addObject(road, 601, 394);
road.setLocation(601, 394);
FighterOne fighterone = new FighterOne();
addObject(fighterone, 258, 278);
fighterone.setLocation(1085, 290);
fighterone.setLocation(1181, 292);
road.setLocation(867, 147);
removeObject(road);
removeObject(fighterone);
Road road2 = new Road();
addObject(road2, 602, 394);
road2.setLocation(601, 394);
FighterOne fighterone2 = new FighterOne();
addObject(fighterone2, 200, 300);
hitBoxOne hitboxone = new hitBoxOne();
addObject(hitboxone, 200, 300);
FighterTwo fightertwo2 = new FighterTwo();
addObject(fightertwo2, 1000, 300);
hitBoxTwo hitboxtwo = new hitBoxTwo();
addObject(hitboxtwo, 1000, 300);
FIGHT FIGHT = new FIGHT();
addObject(FIGHT, 600 , 150);
addObject(bartwo, 900, 60);
addObject(barone, 300, 60);
}
public void act()
{
if (soundCounterOne >= 1)
{
soundCounterOne--;
fight.play();
started();
}
FighterOneDeath = barone.getValue();
FighterTwoDeath = bartwo.getValue();
worldCounter();
setWorld();
if (FighterOneDeath < 1)
{
setWorldTrue = true;
if (getObjects(GameOver.class).isEmpty()) showGameOverTwo();
return;
}
if (FighterTwoDeath < 1)
{
setWorldTrue = true;
if (getObjects(GameOver.class).isEmpty()) showGameOver();
return;
}
}
private void showGameOver()
{
addObject(new GameOver(), getWidth() / 2, getHeight() / 2);
}
private void showGameOverTwo()
{
addObject(new GameOverTwo(), getWidth() / 2, getHeight() / 2);
}
private void worldCounter()
{
if (setWorldTrue == true)
{
setWorldCounter++;
}
}
public void started()
{
music.playLoop();
}
public void stopped()
{
music.stop();
}
private void setWorld()
{
if(setWorldCounter >= 200)
{
setWorldCounter = 0;
setWorldTrue = false;
stopped();
Greenfoot.setWorld(new StartWorld());
}
}
}
Everything works fine in greenfoot, but whenever I try to export, it doesn't work. I also tried to put the jar file in a directory with all of the image files, and it still doesn't work.
