/** * Create physics body and attach to physics world. * * @param e physics entity */ private void createBody(Entity e) { PhysicsComponent physics = e.getComponent(PhysicsComponent.class); physics.setWorld(this); // if position is 0, 0 then probably not set, so set ourselves if (physics.bodyDef.getPosition().x == 0 && physics.bodyDef.getPosition().y == 0) { physics.bodyDef.getPosition().set(toPoint(e.getCenter())); } if (physics.bodyDef.getAngle() == 0) { physics.bodyDef.setAngle((float) -Math.toRadians(e.getRotation())); } physics.body = jboxWorld.createBody(physics.bodyDef); createFixtures(e); createSensors(e); physics.body.setEntity(e); physics.onInitPhysics(); }
/** * Create physics body and attach to physics world. * * @param e physics entity */ private void createBody(Entity e) { PhysicsComponent physics = e.getComponent(PhysicsComponent.class); // if position is 0, 0 then probably not set, so set ourselves if (physics.bodyDef.getPosition().x == 0 && physics.bodyDef.getPosition().y == 0) { physics.bodyDef.getPosition().set(toPoint(e.getCenter())); } if (physics.bodyDef.getAngle() == 0) { physics.bodyDef.setAngle((float) -Math.toRadians(e.getRotation())); } physics.body = jboxWorld.createBody(physics.bodyDef); createFixtures(e); if (physics.isGenerateGroundSensor()) { createGroundSensor(e); } createSensors(e); physics.body.setEntity(e); physics.onInitPhysics(); }