コード例 #1
0
  private void loadAllAssets() {
    logger.debug("Loading All Assets");

    loadEntities();
    loadWeapons();
    for (String s : manifest.images) {
      logger.debug("Image: " + s);
      assetManager.load(s, Texture.class);
    }
    for (String s : manifest.textures) {
      assetManager.load(s, TextureAtlas.class);
    }
    for (String s : manifest.particles) {
      assetManager.load(s, ParticleEffect.class);
    }

    logger.debug("AssetManager begin loading...");
    try {
      while (assetManager.update() == false) {
        drawProgress();
        // logger.debug("  " + (int)(assetManager.getProgress()*100) + "% complete");
      }
    } catch (Exception e) {
      logger.error("Some assets failed to load: " + e.getMessage());
    }
  }
コード例 #2
0
 private void loadAllAssetsInPath(String folder, Class type, String suffix) {
   logger.debug("Loading '" + folder + "'");
   for (FileHandle f : getAssetsPath(folder).list()) {
     String msg = "  Found: " + f.name();
     if (suffix == null) {
       assetManager.load(folder + "/" + f.name(), type);
     } else if (f.name().toLowerCase().endsWith(suffix))
       assetManager.load(folder + "/" + f.name(), type);
     else msg += " ...ignoring";
     logger.debug(msg);
   }
 }
コード例 #3
0
 // Json read
 @Override
 public void read(Json json, JsonValue jsonData) {
   logger.debug("Deserializing");
   PhysicsConfig config = json.fromJson(PhysicsConfig.class, jsonData.toString());
   collisionEffect = config.collisionEffect;
   this.buildFromModel(config.sceneModel);
 }
コード例 #4
0
 // Create everything from a SceneModel. (SceneModels are easily serialized)
 private void buildFromModel(PhysicsSceneModel physicsModel) {
   logger.debug("Build from physics scene model");
   scene.createFromModel(physicsModel);
   for (Body b : scene.getBodies()) {
     b.setUserData(this);
   }
 }
コード例 #5
0
 // Json Write
 @Override
 public void write(Json json) {
   logger.debug("Serializing..");
   PhysicsConfig config = new PhysicsConfig();
   config.collisionEffect = collisionEffect;
   config.sceneModel = scene.toSceneModel();
   json.writeFields(config);
 }
コード例 #6
0
 private void loadWeapons() {
   logger.debug("Loading Weapons");
   Json json = new Json();
   for (String s : manifest.weapons) {
     try {
       WeaponConfig config = json.fromJson(WeaponConfig.class, Gdx.files.internal(s));
       weaponConfigs.put(config.name, config);
     } catch (SerializationException ex) {
       logger.error("Failed to load weapons file: " + s);
       logger.error(ex.getMessage());
     }
   }
 }
コード例 #7
0
  private void loadEntities() {
    logger.debug("Loading Entities");

    Json json = new Json();
    for (String s : manifest.entities) {
      try {
        EntityConfig config = json.fromJson(EntityConfig.class, Gdx.files.internal(s));
        entityConfigs.put(config.name, config);
      } catch (SerializationException ex) {
        logger.error("Failed to load entity file: " + s);
        logger.error(ex.getMessage());
      }
    }
  }
コード例 #8
0
 public Assets() {
   logger.debug("Initializing");
   loadManifest();
   loadAllAssets();
 }
コード例 #9
0
 public String addJoint(JointModel jm) {
   logger.debug("Add joint model");
   logger.error("addJoint(JointModel jm) may not function correctly");
   scene.createJoint(jm);
   return jm.name;
 }
コード例 #10
0
 // Create and add body using a BodyModel. A unique name is automatically generated and returned
 public String addBody(BodyModel bm) {
   logger.debug("Add body model");
   Body b = scene.createBody(bm);
   b.setUserData(this);
   return bm.name;
 }
コード例 #11
0
 // Add Existing body
 public String addBody(Body b) {
   logger.debug("Add body");
   b.setUserData(this);
   return scene.addBody(b);
 }
コード例 #12
0
 // Destroy Joint
 public void destroyJoint(String name) {
   logger.debug("Destroy Joint: " + name);
   scene.destroyJoint(name);
 }
コード例 #13
0
 // Destroy specific fixture
 public void destroyFixture(String name) {
   logger.debug("Destroy fixture: " + name);
   scene.destroyFixture(name);
 }
コード例 #14
0
 // Destroy specific body
 public void destroyBody(String name) {
   logger.debug("Destroy body: " + name);
   scene.destroyBody(name);
 }
コード例 #15
0
 // Destroy everything
 public void destroy() {
   logger.debug("Destroy Everything");
   scene.destroy();
   collisionNormal = 0;
 }