/** * Creates a fixture from a shape and attach it to this body. * This is a convenience function. * Use FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. * If the density is non-zero, this function automatically updates the mass of the body. * Note: this function is locked during callbacks. * * * @param shape the shape to be cloned. * @param density the shape density (set to zero for static bodies). */ public Fixture createFixture(Shape shape, float density) { fixDef.setShape(shape); fixDef.setDensity(density); return createFixture(fixDef); }
/** * Creates a fixture from a shape and attach it to this body. * This is a convenience function. * Use FixtureDef if you need to set parameters like friction, restitution, user data, or filtering. * If the density is non-zero, this function automatically updates the mass of the body. * Note: this function is locked during callbacks. * * * @param shape the shape to be cloned. * @param density the shape density (set to zero for static bodies). */ public Fixture createFixture(Shape shape, float density) { fixDef.setShape(shape); fixDef.setDensity(density); return createFixture(fixDef); }
private void createFixtures(Entity e) { BoundingBoxComponent bbox = e.getBoundingBoxComponent(); PhysicsComponent physics = e.getComponent(PhysicsComponent.class); // TODO: same fixture def for every fixture? FixtureDef fd = physics.fixtureDef; for (HitBox box : bbox.hitBoxesProperty()) { Shape b2Shape = createShape(box, e); // we use definitions from user, but override shape fd.setShape(b2Shape); Fixture fixture = physics.body.createFixture(fd); fixture.setHitBox(box); } }
private void createFixtures(Entity e) { BoundingBoxComponent bbox = e.getBoundingBoxComponent(); PhysicsComponent physics = e.getComponent(PhysicsComponent.class); // TODO: same fixture def for every fixture? FixtureDef fd = physics.fixtureDef; for (HitBox box : bbox.hitBoxesProperty()) { Shape b2Shape = createShape(box, e); // we use definitions from user, but override shape fd.setShape(b2Shape); Fixture fixture = physics.body.createFixture(fd); // TODO: setHitBox()? fixture.setUserData(box); } }