I am trying to operate a public method that is in an abstract class. I tried to operate that method from inside a public method that inside a public class that extends an other abstract class, but the compiler gave me:
"non-static method method_name() cannot be referenced from a static context"
What do I need in order to make it operate that method ?
public class Dingo extends Animal
{
public void act()
{
if (kangarooCrossing())
{
Weapon.killAnimalMySquare(); //<<<<<<<<<< THE Problematic line
}
if(canMove())
move();
else
changeDirection();
}
// returns true if a Kangaroo is crossing.
private boolean kangarooCrossing()
{
Actor kangaroo = getOneObjectAtOffset(0, 0, Kangaroo.class);
if(kangaroo != null) {
return true;
}
else {
return false;
}
}
}
abstract class Weapon extends Actor
{
/**Kills an animal that steps on current square*/
public void killAnimalMySquare()
{
Actor animal = getOneObjectAtOffset(0, 0, Animal.class);
if(animal != null)
getWorld().removeObject(animal);
}
/**returns true if an animal is crossing*/
public boolean animalCrossing()
{
Actor animal = getOneObjectAtOffset(0, 0, Animal.class);
if(animal != null)
return true;
return false;
}
}
thnx !!!