Is it possible to define a more accurate collision region with a specific shape, rather than a rectangle for an object?

Is it possible to define a more accurate collision region with a specific shape, rather than a rectangle for an object? Please let me know if this is possible and how?

+3
source share
1 answer

Of course, this is possible, and there are several possible solutions:

However, Box2D is a little heavy if you only want to make some kind of custom encounter with the form.

  • : ImpactJS - , , :
    • ig.Game.checkEntities, , .
    • ig.Entity.check, , , , , ( ).

ig.Entity.check :

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.
+3

All Articles