I want to delete an object I created, (e.g. an oval that follows you), but how would I do this? I ran the statement:
delete follower1;
but it didn't work.
Background:
I'm making a small game with a oval you can control, and a oval which follows you. Now I've got files named: DrawPanel.class, this class draws everything on the screen, and handles collisions, sounds, etc. I also have enemy.class, which is the oval following the player. I also have entity.class, which is the player you can control. And if the player intersects with the follower (the enemy), I want my player object to get deleted. Currently, the way I'm doing it is:
public void checkCollisions(){
if(player.getBounds().intersects(follower1.getBounds())){
Follower1Alive = false;
player.health = player.health - 10;
}
}