Hi,
I have a problem with my small programm. I'm trying to access a method from another class. I followed this tutorial but I still have this problem.
Here is my error message and lines :
java.lang.NullPointerException
at Bacterie.touchUnder(Bacterie.java:28)
at Bacterie.act(Bacterie.java:15)
Lines shown :
Here is the code in my Espace3 World :
And finally the indicator itself (eIndicator.class)
Thank you very much and sorry for my bad english
getWorld().removeObject(this); Espace3 Espace3World = (Espace3) getWorld(); eIndicator eindicator = Espace3World.getIndicator(); //this line eindicator.getEnergy(1);
private eIndicator theIndicator; //In Espace3 method theIndicator = new eIndicator(); addObject(theIndicator, 1050, 640); //------------------ public eIndicator getIndicator() { return theIndicator; }
private int energieRestante; public eIndicator() { setImage("4e.png"); } public void act() { } public void getEnergy(int howMuch) { energieRestante += howMuch; if(energieRestante == 4) { setImage("4e.png"); } else if(energieRestante == 3) { setImage("3e.png"); } else if(energieRestante == 2) { setImage("2e.png"); } else if(energieRestante == 1) { setImage("1e.png"); } else if(energieRestante == 0) { Greenfoot.stop(); } }