I have a problem in my space shooter game where when the Bullet hits the Asteroid the Asteroid is supposed dissapear and debris is supposed to appear. However when a Bullet hits the Asteroid, the Asteroid instead moves backwards a bit and then the entire game slows down and just stops. No errors come up but its acting as though the RAM was so full it just slowed down to nothing.
This is the code in my Asteroid class.
public class Asteroid extends Actor { int margin = getImage().getWidth()/2 - 8; private int size; /** * Act - do whatever the Asteroid wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { move(-7); // if (checkEdge() == true){ // getWorld().removeObject(this); // } checkHit(); } public boolean checkEdge() { if (getX() - margin < 0) { return true; } return false; } public void checkHit() { Bullet b = getOneIntersectingObject(Bullet.class); if(b != null) { Asteroid a1 = new Asteroid(); Asteroid a2 = new Asteroid(); getWorld().addObject(a1, getX(), getY()); getWorld().addObject(a2, getX(), getY()); a1.move(11); a2.move(11); getWorld().removeObject(this); } } } // public boolean checkEdge() // { // if (getX() - margin < 0) { // return true; // } // return false; // }