Of course it is possible, and there are multiple possible solutions:
- Box2D: is a great physics engine, and available as a plugin for ImpactJS, you can learn how to use this plugin at impactjs.com/documentation/physics-with-box2d
However, Box2D is a bit heavy if you only want to do some custom shape collision.
- Custom Entity Collision Check: ImpactJS is a great game engine, it lets you easily extend any of its modules, and for custom entity collision check there are two possible methods:
- extend the
ig.Game.checkEntities
, this allows you to loop through all entities in the game and check their collisions the way you want to. - extend the
ig.Entity.check
, for lazy people like myself, and only when the custom shape is contained within the entity's rectangle, you can do the entity shape collision check within this function (after entity rectangle collision has already occurred).
- extend the
ig.Entity.check
example:
MyEntity = ig.Entity.extend({
customShape: 'circle',
// custom shape definition...
customShapeProperties: {radius: 0},
check: function(other) {
// custom shape collision check...
if (...) {
this.customCheck(other);
}
},
customCheck: function(body) {}
});
// now if all your entities inherit MyEntity,
// they will have customCheck called only when the custom shape collision occur.