O'Reilly logo

Building HTML5 Games with ImpactJS by Jesse Freeman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Killing Entities

You may have noticed while we set up our weapons that we called a built-in method called kill(). While reducing an entity’s life will destroy it and automatically call kill() for you, there are times when you may need to do this manually—like when the grenade collides with an enemy or it bounces too much. This method actually completely removes the entity from the render list, so it is a helpful way to permanently remove entities from the game. If you do not call kill() on anything you need to remove from the game, things will start to slow down considerably, so make sure you take advantage of the kill() method.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required