Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by eruciform

Something to this effect:

    createBody: function() {
      var bodyDef = new b2.BodyDef();
      bodyDef.position.Set(
        (this.pos.x + this.size.x / 2) * b2.SCALE,
        (this.pos.y + this.size.y / 2) * b2.SCALE
      );  
      this.defineBody(bodyDef); // OVERRIDE IF DESIRED
      this.body = ig.world.CreateBody(bodyDef);
      var shapeDef = new b2.PolygonDef();
      shapeDef.SetAsBox(
        this.size.x / 2 * b2.SCALE,
        this.size.y / 2 * b2.SCALE
      );  
      shapeDef.density = 1;
      this.defineShape(shapeDef); // OVERRIDE IF DESIRED
      this.body.CreateShape(shapeDef);
      this.body.SetMassFromShapes();
    },  
    defineBody: function(bodyDef){},
    defineShape: function(shapeDef){},

Would allow things like this much easier in a Box2DEntity:

  defineShape: function(shapeDef) {
    shapeDef.filter.groupIndex = -1; 
  },  

Which would (for example, in the case I was trying to solve) allow you to have all bullets ignore each other in the physics box2d demo.

1 decade ago by eruciform

I guess you could theoretically override the b2.World class with Class.inject to edit the definition of CreateBody, in a plugin... that's pretty deep monkeying though...
Page 1 of 1
« first « previous next › last »