Going crazy trying to figure out why my counter (the one imported from within Greenfoot)
wont work:
I have the following in MyWorld:
Counter counter = new Counter();
I have the following in my Player (to get a point when it eats something)
Note, that the commented out code works. But why does it not work as it stands now?
public Counter getCounter()
{
return counter;
}
public void act()
{
Actor eat = getOneObjectAtOffset(0,0, Food.class);
if (eat != null)
{
getWorld().removeObject(eat);
//World world;
//world = getWorld();
//Counter counter = (Counter) (getWorld().getObjects(Counter.class).get(0));
//counter.add(1);
MyWorld world;
world = (MyWorld)getWorld();
Counter counter = world.getCounter();
counter.add(1);
}


