Ejemplo n.º 1
0
  private void createPlanet() {

    // 1. Create a BodyDef, as usual.
    BodyDef bd = new BodyDef();
    // bd.type = BodyType.KinematicBody;
    bd.type = BodyType.KinematicBody;

    // 2. Create a FixtureDef, as usual.
    FixtureDef fd = new FixtureDef();
    // A kinematic body behaves as if it has infinite mass
    fd.friction = 0.5f;
    fd.restitution = 0.3f;
    fd.filter.categoryBits = CATEGORY_PLANET;
    fd.filter.maskBits = MASK_PLANET;

    // 3. Create a Body, as usual.
    planetModel = world.createBody(bd);

    // 4. Create the body fixture automatically by using the loader.
    loader.attachFixture(planetModel, "planet", fd, PLANET_WIDTH);
    planetModelOrigin = loader.getOrigin("planet", PLANET_WIDTH).cpy();
  }
Ejemplo n.º 2
0
  private void createPlanetCore() {

    // 1. Create a BodyDef, as usual.
    BodyDef bd = new BodyDef();
    // bd.type = BodyType.KinematicBody;
    bd.type = BodyType.DynamicBody;
    // bd.active = false;//This means the body will not participate in collisions, ray casts, etc.

    // 2. Create a FixtureDef, as usual.
    FixtureDef fd = new FixtureDef();
    // A kinematic body behaves as if it has infinite mass fd.density = 1000000;
    fd.friction = 0.5f;
    fd.restitution = 0.3f;
    fd.filter.categoryBits = CATEGORY_CORE_PLANET;
    fd.filter.maskBits = MASK_CORE_PLANET;

    // 3. Create a Body, as usual.
    planetCoreModel = world.createBody(bd);

    // 4. Create the body fixture automatically by using the loader.
    loader.attachFixture(planetCoreModel, "planet_core", fd, PLANET_CORE_WIDTH);
    planetCoreModelOrigin = loader.getOrigin("planet_core", PLANET_CORE_WIDTH).cpy();
  }