I cannot tell you what the problem is but this is my code:
public void act()
{
MouseInfo mouse = Greenfoot.getMouseInfo();
if (mouse != null)
{
List objects = getWorld().getObjectsAt(mouse.getX(), mouse.getY(), TeamA1.class);
for (Object object : objects)
{
if (object == this)
{
b spaceWorld = (b) getWorld();
Overallscore counter = spaceWorld.getOverallscore();
if(b == 0)
{
setImage(new GreenfootImage("?", 28, Color.BLACK, Color.WHITE));
b = 1;
}
if(Greenfoot.isKeyDown("0")){
setImage(new GreenfootImage("0", 28, Color.BLACK, Color.WHITE));
}
if(Greenfoot.isKeyDown("1")){
setImage(new GreenfootImage("1", 28, Color.BLACK, Color.WHITE));
counter.TeamA11();
}
if(Greenfoot.isKeyDown("2")){
setImage(new GreenfootImage("2", 28, Color.BLACK, Color.WHITE));
counter.TeamA12();
}
if(Greenfoot.isKeyDown("3")){
setImage(new GreenfootImage("3", 28, Color.BLACK, Color.WHITE));
counter.TeamA13();
}
if(Greenfoot.isKeyDown("4")){
setImage(new GreenfootImage("4", 28, Color.BLACK, Color.WHITE));
counter.TeamA14();
}
if(Greenfoot.isKeyDown("5")){
setImage(new GreenfootImage("5", 28, Color.BLACK, Color.WHITE));
counter.TeamA15();
}
if(Greenfoot.isKeyDown("6")){
setImage(new GreenfootImage("6", 28, Color.BLACK, Color.WHITE));
counter.TeamA16();
}
if(Greenfoot.isKeyDown("7")){
setImage(new GreenfootImage("7", 28, Color.BLACK, Color.WHITE));
counter.TeamA17();
}
if(Greenfoot.isKeyDown("8")){
setImage(new GreenfootImage("8", 28, Color.BLACK, Color.WHITE));
counter.TeamA18();
}
if(Greenfoot.isKeyDown("9")){
setImage(new GreenfootImage("9", 28, Color.BLACK, Color.WHITE));
counter.TeamA19();
}
}
}
}
in my world class i have
private Overallscore theCounter;
public Overallscore getOverallscore()
{
return theCounter;
}
in the next class there is:
public void TeamA11()
{
Am1 = 1;
}
public void TeamA12()
{
Am1 = 2;
}
public void TeamA13()
{
Am1 = 3;
}
public void TeamA14()
{
Am1 = 4;
}
public void TeamA15()
{
Am1 = 5;
}
public void TeamA16()
{
Am1 = 6;
}
public void TeamA17()
{
Am1 = 7;
}
public void TeamA18()
{
Am1 = 8;
}
public void TeamA19()
{
Am1 = 9;
}
the error is
java.lang.NullPointerException
at TeamA1.act(TeamA1.java:93)
at greenfoot.core.Simulation.actActor(Simulation.java:568)
at greenfoot.core.Simulation.runOneLoop(Simulation.java:526)
at greenfoot.core.Simulation.runContent(Simulation.java:215)
at greenfoot.core.Simulation.run(Simulation.java:205
please help

