This site requires JavaScript, please enable it in your browser!
Greenfoot back
ando600
ando600 wrote ...

2015/11/5

My scenario wont export to a jar file.

ando600 ando600

2015/11/5

#
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.
ando600 ando600

2015/11/6

#
Guys I really need help. Please reply.
lordhershey lordhershey

2015/11/12

#
How are you exporting the jar? Have you tried doing the executable jar? What about uploading to the site?
ando600 ando600

2015/11/13

#
I am using the export tool at the top of the greenfoot software, and selecting jar file. I need to export to a jar file as it is for a school project.
lordhershey lordhershey

2015/11/13

#
Are there any exceptions thrown when you run the jar, or are you trying to view the jar like you would on web page? There are a couple of export options at the tabs one is for executable jar and the other is for non greenfoot site web page. If you do the latter, you cannot simply click on the index.html file and see the applet, you would see a blank play field with a red x in the corner and no part of the program would be running. I haven't exported anything for a while, I will have to look at the options again.
ando600 ando600

2015/11/16

#
I don't see a red x. It is just a white screen. I am doing this for a computer science class. My whole class exported it the same way, and didn't have problems. I will try anything you think may work.
lordhershey lordhershey

2015/11/16

#
I'd ask the instructor or lab assistant if they are willing to help . To get a jar I click the Export Button then select Application - take note of where it wants to drop the file. If you do an export to web page you get a directory with a html file and 2 jar files, if you are missing one of those jar files you will not be able to view the html file. Can you take a screen shot of the export option and shoot an email to me - I have bobo@lordhershey.com
You need to login to post a reply.