Hi
im trying to make a reference to the enemy class so when the bullet makes impact a life is removed. So far I have:
I have this written in my main enemy class:
The hunter enemy I have given it a life of 100 using a constructor:
the bullet uses getOneIntersectingObject to check collision with the hunter using:
I used the howto-1 tutorial for the counter, but wasnt too sure how to reference the enemy class.
public void takeLife(){ life = life - 1; }
public Hunter() { this.life = 100; }
Actor collided2 = getOneIntersectingObject(Hunter.class); if (collided2 != null){ getWorld().addObject(new explosionLarge(), getX(), getY()); City cityWorld = (City) getWorld(); // get a reference to the world // getWorld().removeObject(collided); Counter counter = cityWorld.getCounter(); // get a reference to the counter counter.add(20); getWorld().removeObject(this); return; }