I have a game over class but when i try to put it into the world i get an error.
the code in the game over class is
java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: heath0 at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:293) at greenfoot.GreenfootImage.<init>(GreenfootImage.java:109) at HeathBar.<init>(HeathBar.java:37) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at greenfoot.core.Simulation.newInstance(Simulation.java:578) at greenfoot.localdebugger.LocalDebugger$QueuedInstantiation.run(LocalDebugger.java:155) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:465) at greenfoot.core.Simulation.maybePause(Simulation.java:279) at greenfoot.core.Simulation.runContent(Simulation.java:210) at greenfoot.core.Simulation.run(Simulation.java:203) Caused by: java.io.FileNotFoundException: Could not find file: heath0 at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:534) at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:290) ... 12 more java.lang.IllegalArgumentException: Filename 'heath2.png' has the wrong case. It should be: 'Heath2.png' at greenfoot.util.GreenfootUtil.checkCase(GreenfootUtil.java:564) at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:531) at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:290) at greenfoot.GreenfootImage.<init>(GreenfootImage.java:109) at HeathBar.<init>(HeathBar.java:39) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at greenfoot.core.Simulation.newInstance(Simulation.java:578) at greenfoot.localdebugger.LocalDebugger$QueuedInstantiation.run(LocalDebugger.java:155) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:465) at greenfoot.core.Simulation.maybePause(Simulation.java:279) at greenfoot.core.Simulation.runContent(Simulation.java:210) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getX(Actor.java:157) at All.atWorldEdge(All.java:32) at Ant.moveAround(Ant.java:26) at Ant.act(Ant.java:18) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:867) at All.canSee(All.java:47) at Normal.checkCollision(Normal.java:46) at Normal.act(Normal.java:33) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:867) at All.canSee(All.java:47) at Turrent.lineCheck(Turrent.java:149) at Turrent.act(Turrent.java:39) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:867) at All.canSee(All.java:47) at Turrent.lineCheck(Turrent.java:149) at Turrent.act(Turrent.java:39) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:867) at All.canSee(All.java:47) at Turrent.lineCheck(Turrent.java:150) at Turrent.checkCollision(Turrent.java:137) at Turrent.act(Turrent.java:39) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.NullPointerException at GameOver.updateImage(GameOver.java:21) at GameOver.<init>(GameOver.java:10) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at greenfoot.core.Simulation.newInstance(Simulation.java:578) at greenfoot.localdebugger.LocalDebugger$QueuedInstantiation.run(LocalDebugger.java:155) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:465) at greenfoot.core.Simulation.maybePause(Simulation.java:279) at greenfoot.core.Simulation.runContent(Simulation.java:210) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.NullPointerException at GameOver.updateImage(GameOver.java:21) at GameOver.<init>(GameOver.java:16) at __SHELL21$1.<init>(__SHELL21.java:17) at __SHELL21.run(__SHELL21.java:14) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at greenfoot.localdebugger.LocalDebugger$QueuedExecution.run(LocalDebugger.java:267) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:465) at greenfoot.core.Simulation.maybePause(Simulation.java:279) at greenfoot.core.Simulation.runContent(Simulation.java:210) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:867) at All.canSee(All.java:47) at Turrent.lineCheck(Turrent.java:151) at Turrent.checkCollision(Turrent.java:138) at Turrent.act(Turrent.java:39) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:663) at greenfoot.Actor.getOneObjectAtOffset(Actor.java:867) at All.canSee(All.java:47) at Turrent.lineCheck(Turrent.java:151) at Turrent.checkCollision(Turrent.java:138) at Turrent.act(Turrent.java:39) at greenfoot.core.Simulation.actActor(Simulation.java:565) at greenfoot.core.Simulation.runOneLoop(Simulation.java:523) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.NullPointerException at GameOver.updateImage(GameOver.java:21) at GameOver.<init>(GameOver.java:10) at Mw.endScreen(Mw.java:44) at Mw.act(Mw.java:31) at greenfoot.core.Simulation.actWorld(Simulation.java:571) at greenfoot.core.Simulation.runOneLoop(Simulation.java:506) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.NullPointerException at GameOver.updateImage(GameOver.java:21) at GameOver.<init>(GameOver.java:10) at Mw.endScreen(Mw.java:44) at Mw.act(Mw.java:31) at greenfoot.core.Simulation.actWorld(Simulation.java:571) at greenfoot.core.Simulation.runOneLoop(Simulation.java:506) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203) java.lang.NullPointerException at GameOver.updateImage(GameOver.java:21) at GameOver.<init>(GameOver.java:10) at Mw.endScreen(Mw.java:44) at Mw.act(Mw.java:31) at greenfoot.core.Simulation.actWorld(Simulation.java:571) at greenfoot.core.Simulation.runOneLoop(Simulation.java:506) at greenfoot.core.Simulation.runContent(Simulation.java:213) at greenfoot.core.Simulation.run(Simulation.java:203)
import greenfoot.*; import java.awt.Color; public class GameOver extends Actor { String msgTxt = "GAME OVER"; public GameOver() { updateImage(); } public GameOver(String txt) { msgTxt = txt; updateImage(); } private void updateImage() { GreenfootImage image = new GreenfootImage(getWorld().getWidth(), getWorld().getHeight()); // or whatever size you want the object image.setColor(Color.cyan); // color of your choice image.fill(); GreenfootImage txtImg = new GreenfootImage(msgTxt, 36, Color.black, new Color(0, 0, 0, 0)); // colors and font size of your choice image.drawImage(txtImg, (image.getWidth() - txtImg.getWidth()) / 2, (image.getHeight() - txtImg.getHeight() / 2)); // whatever else you might want to do for the image setImage(image); } }