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

type Property

The .type property allows us to group entities when doing collision detection. For example, you might assign all friendly entities to one group, and all enemy entities to another group. This way, you can set up your file so neither group will collide with their own types, but friendlies will collide with enemies, and vice versa. There are three .types in Impact that you can reference using their constant values:

ig.Entity.TYPE.NONE
ig.Entity.TYPE.A
ig.Entity.TYPE.B

By default, all entities are set to NONE. The other two groups are left open for your own needs. So, for instance, you can set all friendly entities to TYPE.A and hostile entities will check for collisions with TYPE.A only.

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