This site requires JavaScript, please enable it in your browser!
Greenfoot back
IlikeThePrequels
IlikeThePrequels wrote ...

2018/4/11

Could anyone explain how to make a bullet and an enemy diasappear when they collide?

IlikeThePrequels IlikeThePrequels

2018/4/11

#
I've been trying to find a solution but have not found one yet. Here is my code. public void checkCollision() { Actor bee2 = (Actor) getOneIntersectingObject(Bee2.class); if(bee2 != null) { getWorld().removeObject(bee2); } if (isTouching(Stinger.class)) { getWorld().removeObject(this); return; } } This code causes the bullet to hit the enemy and make it disappear but the bullet continues on traveling until it reaches the end of the world.
You need to login to post a reply.