Me and my mates are creating a space game and we are stuck on the hit detection we want are bullet(class called lazer) to when it hits the enemy(named enemy1) to both disappear when hit. Please may someone suggest some code
public void act(){
setLocation(getX()+15, getY());
if( getX() <=4 || getX() >= getWorld().getWidth()-2)
{
getWorld().removeObject(this);
return;
}
}
public void hitDetection() {
Actor Lazer = getOneIntersectingObject(Enemy1.class);
if( Lazer != null)
{
getWorld().removeObject(Lazer);
getWorld().removeObject(this);
}
}
// insert between lines 9 and 10 above hitDetection();