コード例 #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
 public InputStream getInputStream() {
   try {
     // if (logger.isInfoEnabled())
     if (logger.getLevel() >= Logger.INFO) logger.info("loading stream " + getResourceName());
     return new FileInputStream(new File(path));
   } catch (FileNotFoundException e) {
     throw new RuntimeException("File for " + resourceName + " not found", e);
   }
 }
コード例 #3
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);
   }
 }
コード例 #4
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());
     }
   }
 }
コード例 #5
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());
      }
    }
  }
コード例 #6
0
 public EntityConfig getEntityConfig(String name) {
   if (entityConfigs.containsKey(name)) return entityConfigs.get(name);
   else if (entityConfigs.containsKey("entities/" + name))
     return entityConfigs.get("entities/" + name);
   logger.error("Entity config not found: " + name);
   return null;
 }
コード例 #7
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);
   }
 }
コード例 #8
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);
 }
コード例 #9
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);
 }
コード例 #10
0
  public WeaponConfig getWeaponConfig(String name) {
    if (weaponConfigs.containsKey(name)) return weaponConfigs.get(name);
    else if (weaponConfigs.containsKey("weapons/" + name))
      return weaponConfigs.get("weapons/" + name);

    logger.error("Weapon config not found: " + name);
    return null;
  }
コード例 #11
0
 public Texture getTexture(String name) {
   Texture tex = null;
   String[] possibles = {name, "data/" + name, "data/images/" + name, "data/textures/" + name};
   for (String s : possibles) {
     if (assetManager.isLoaded(s)) tex = assetManager.get(s);
   }
   if (tex == null) logger.error("Texture not found: " + name);
   return tex;
 }
コード例 #12
0
 public ParticleEffect getEffect(String name) {
   ParticleEffect eff = null;
   String[] possibles = {
     name, "data/" + name, "data/particles/" + name,
   };
   for (String s : possibles) {
     if (assetManager.isLoaded(s)) eff = assetManager.get(s);
   }
   if (eff == null) logger.error("ParticleEffect not found: " + name);
   return eff;
 }
コード例 #13
0
 public Assets() {
   logger.debug("Initializing");
   loadManifest();
   loadAllAssets();
 }
コード例 #14
0
 // Destroy specific fixture
 public void destroyFixture(String name) {
   logger.debug("Destroy fixture: " + name);
   scene.destroyFixture(name);
 }
コード例 #15
0
 // Destroy specific body
 public void destroyBody(String name) {
   logger.debug("Destroy body: " + name);
   scene.destroyBody(name);
 }
コード例 #16
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;
 }
コード例 #17
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;
 }
コード例 #18
0
 // Add Existing body
 public String addBody(Body b) {
   logger.debug("Add body");
   b.setUserData(this);
   return scene.addBody(b);
 }
コード例 #19
0
 // Destroy everything
 public void destroy() {
   logger.debug("Destroy Everything");
   scene.destroy();
   collisionNormal = 0;
 }
コード例 #20
0
 // Destroy Joint
 public void destroyJoint(String name) {
   logger.debug("Destroy Joint: " + name);
   scene.destroyJoint(name);
 }