The Error:
java.lang.NullPointerException
at Dragonoir.act(Dragonoir.java:24)
at greenfoot.core.Simulation.actActor(Simulation.java:507)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:470)
at greenfoot.core.Simulation.runContent(Simulation.java:204)
at greenfoot.core.Simulation.run(Simulation.java:194)
java.lang.NullPointerException
at Dragonoir.act(Dragonoir.java:24)
at greenfoot.core.Simulation.actActor(Simulation.java:507)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:470)
at greenfoot.core.Simulation.runContent(Simulation.java:204)
at greenfoot.core.Simulation.run(Simulation.java:194)
Line 24:
myDHealthbar.healthcheck();
healthcheck method:
I'm not sure how to resolve it =/
public void healthcheck() { if(gethealth() < 25) {setImage("0.png"); }else if(gethealth() > 25 && gethealth() <= 75) {setImage("50.png"); }else if(gethealth() > 75 && gethealth() <= 125) {setImage("100.png"); }else if(gethealth() > 125 && gethealth() <= 175) {setImage("150.png"); }else if(gethealth() > 175 && gethealth() <= 225) {setImage("200.png"); }else if(gethealth() > 225 && gethealth() <= 275) {setImage("250.png"); }else if(gethealth() > 275 && gethealth() <= 325) {setImage("300.png"); }else if(gethealth() > 325 && gethealth() <= 375) {setImage("350.png"); }else if(gethealth() > 375 && gethealth() <= 425) {setImage("400.png"); }else if(gethealth() > 425 && gethealth() <= 475) {setImage("450.png"); }else if(gethealth() > 475 && gethealth() <= 525) {setImage("500.png"); }else if(gethealth() > 525 && gethealth() <= 575) {setImage("550.png"); }else if(gethealth() > 575 && gethealth() <= 625) {setImage("600.png"); }else if(gethealth() > 625 && gethealth() <= 675) {setImage("650.png"); }else if(gethealth() > 675 && gethealth() <= 725) {setImage("700.png"); }else if(gethealth() > 725 && gethealth() <= 775) {setImage("750.png"); }else if(gethealth() > 775 && gethealth() <= 825) {setImage("800.png"); }else if(gethealth() > 825 && gethealth() <= 875) {setImage("850.png"); }else if(gethealth() > 875 && gethealth() <= 925) {setImage("900.png"); }else if(gethealth() > 925 && gethealth() <= 975) {setImage("950.png"); }else {setImage("1000.png"); } }