Trying to get have asteroid destroyed on one bullet...any ideas?
public void hit(int damage) {
stability = stability - damage;
if(stability <= 0)
explode();


public class Bullet ... { public void act() { ... if (getWorld().getOneObjectAtOffset(0, 0, Asteriod.class).size() != 0) { getWorld().removeObject(getWorld().getOneObjectAtOffset(0, 0, Asteroid.class)); //removing the asteroid; getWorld().removeObject(this); //remove the bullet. return; //not necessary but if other code follows this there might be Exceptions. } ... } }
// in the Asteroid act method if (seeBullet()) { eatBullet(); explode(); return; } // methods private boolean seeBullet() { return !getObjectsInRange(getWidth() / 2, Bullet.class).isEmpty(); } private eatBullet() { getWorld().removeObject((Bullet) getObjectsInRange(getWidth() / 2, Bullet.class).get(0)); }
private void eatBullet()