Java 类com.badlogic.gdx.utils.JsonValue.JsonIterator 实例源码

项目:libgdxjam    文件:AnimationControlLoader.java   
private void loadTagGroups(JsonValue value) {
    JsonIterator iterator = value.iterator();

    while(iterator.hasNext()) {
        loadTagGroup(iterator.next());
    }
}
项目:libgdxjam    文件:AnimationControlLoader.java   
private void loadLayers(JsonValue value) {
    JsonIterator iterator = value.iterator();
    int track = 0;

    while(iterator.hasNext()) {
        loadLayer(iterator.next(), track++);
    }
}
项目:libgdxjam    文件:AnimationControlLoader.java   
private void loadLayer(JsonValue value, int track) {
    String name = value.name;
    Array<Entry> entries = new Array<Entry>();

    JsonIterator iterator = value.iterator();

    while(iterator.hasNext()) {
        entries.add(loadEntry(iterator.next()));
    }

    data.mutableLayers.add(new Layer(name, entries, track));
}
项目:libgdxjam    文件:AnimationControlLoader.java   
private void loadTransitions(JsonValue value) {
    data.defaultDuration = value.getFloat("defaultDuration");

    if (!value.has("list")) { return; }

    JsonIterator iterator = value.get("list").iterator();

    while (iterator.hasNext()) {
        loadTransition(iterator.next());
    }
}
项目:libgdxjam    文件:PhysicsDataLoader.java   
private void loadFixtureDefs(JsonValue root) {
    JsonValue fixtures = root.get("fixtures");
    JsonIterator fixturesIt = fixtures.iterator();
    int index = 0;

    while (fixturesIt.hasNext()) {
        JsonValue fixture = fixturesIt.next();

        FixtureDef fixtureDef = new FixtureDef();

        fixtureDef.density = fixture.getFloat("density", 1.0f);
        fixtureDef.restitution = fixture.getFloat("restitution", 0.0f);
        fixtureDef.friction = fixture.getFloat("friction", 1.0f);
        fixtureDef.isSensor = fixture.getBoolean("isSensor", false);
        fixtureDef.shape = loadShape(fixture);
        loadFilter(fixture, fixtureDef.filter);
        String id = fixture.getString("id", "");

        logger.info("loading fixture with id " + id);

        physicsData.fixtureNames.add(id);
        physicsData.fixtureIdx.put(id, index);
        physicsData.fixtureDefs.add(fixtureDef);

        ++index;
    }
}
项目:sioncore    文件:EntityFactory.java   
public void loadArchetypes() {
    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(ARCHETYPES_FILE));
        JsonIterator entitiesIt = root.iterator();

        while (entitiesIt.hasNext()) {
            JsonValue entity = entitiesIt.next();
            loadEntityArchetype(Gdx.files.internal(entity.asString()));
        }
    }
    catch (Exception e) {
        logger.error("failed to process entity list " + ARCHETYPES_FILE);
    }
}
项目:sioncore    文件:ParticleEffectPools.java   
public ParticleEffectPools() {
    logger = new Logger(TAG, Env.debugLevel);

    logger.info("initialising");

    pools = new ObjectMap<String, ParticleEffectPool>();

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(PARTICLES_FILE));
        JsonIterator particlesIt = root.iterator();

        while (particlesIt.hasNext()) {
            JsonValue particleValue = particlesIt.next();
            String effectName = particleValue.asString();
            logger.info("loading " + effectName);
            ParticleEffect effect = new ParticleEffect();
            effect.load(Gdx.files.internal(effectName), Gdx.files.internal(PARTICLES_FOLDER));

            pools.put(effectName, new ParticleEffectPool(effect,
                                                         Env.particlePoolInitialCapacity,
                                                         Env.particlePoolMaxCapacity));
        }
    }
    catch (Exception e) {
        logger.error("failed to list directory " + PARTICLES_FILE);
    }
}
项目:sioncore    文件:Assets.java   
private void loadGroups(String assetFile) {
        groups = new ObjectMap<String, Array<Asset>>();

        logger.info("loading file " + assetFile);

//      try {
            Json json = new Json();
            JsonReader reader = new JsonReader();
            JsonValue root = reader.parse(Gdx.files.internal(assetFile));

            JsonIterator groupIt = root.iterator();

            while (groupIt.hasNext()) {
                JsonValue groupValue = groupIt.next();

                if (groups.containsKey(groupValue.name)) {
                    logger.error("group " + groupValue.name + " already exists, skipping");
                    continue;
                }

                logger.info("registering group " + groupValue.name);

                Array<Asset> assets = new Array<Asset>();

                JsonIterator assetIt = groupValue.iterator();

                while (assetIt.hasNext()) {
                    JsonValue assetValue = assetIt.next();

                    Asset asset = json.fromJson(Asset.class, assetValue.toString());
                    assets.add(asset);
                }

                groups.put(groupValue.name, assets);
            }
//      }
//      catch (Exception e) {
//          logger.error("error loading file " + assetFile + " " + e.getMessage());
//      }
    }
项目:sioncore    文件:MapBodyManager.java   
private void loadMaterialsFile(FileHandle materialsFile) {
    logger.info("adding default material");

    FixtureDef fixtureDef = new FixtureDef();
    fixtureDef.density = 1.0f;
    fixtureDef.friction = 1.0f;
    fixtureDef.restitution = 0.0f;
    materials.put("default", fixtureDef);

    logger.info("loading materials file");

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(materialsFile);
        JsonIterator materialIt = root.iterator();

        while (materialIt.hasNext()) {
            JsonValue materialValue = materialIt.next();

            if (!materialValue.has("name")) {
                logger.error("material without name");
                continue;
            }

            String name = materialValue.getString("name");

            fixtureDef = new FixtureDef();
            fixtureDef.density = materialValue.getFloat("density", 1.0f);
            fixtureDef.friction = materialValue.getFloat("friction", 1.0f);
            fixtureDef.restitution = materialValue.getFloat("restitution", 0.0f);
            logger.info("adding material " + name);
            materials.put(name, fixtureDef);
        }

    } catch (Exception e) {
        logger.error("error loading " + materialsFile.name() + " " + e.getMessage());
    }
}
项目:libgdxjam    文件:AnimationStateDataLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, AnimationStateDataLoaderParameter parameter) {
    logger.info("loading " + fileName);

    data = new AnimationStateData(manager.get(parameter.skeletonName, SkeletonData.class));

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        float defaultBlend = root.get("defaultBlend").asFloat();

        logger.info("default blend: " + defaultBlend + "s");

        data.setDefaultMix(defaultBlend);

        JsonIterator blendIt = root.get("blends").iterator();

        while (blendIt.hasNext()) {
            JsonValue blendValue = blendIt.next();
            String from = blendValue.get("from").asString(); 
            String to = blendValue.get("to").asString();
            float duration = blendValue.get("duration").asFloat();

            data.setMix(from, to , duration);

            logger.info("blend: " + from + " -> " + to + " [" + duration + "s]");
        }
    }
    catch (Exception e) {
        logger.error("error loading " + fileName + " " + e.getMessage());
    }
}
项目:sioncore    文件:SpriteAnimationLoader.java   
/**
 * Aynchronously loads the animation data animations
 */
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, AnimationParameter parameter) {
    logger.info("loading " + fileName);

    animationData = new SpriteAnimationData();

    // Retrieve texture
    animationData.texture = manager.get(stripExtension(fileName) + ".png", Texture.class);

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        animationData.rows = root.getInt("rows");
        animationData.columns = root.getInt("columns");
        animationData.frameDuration = root.getFloat("frameDuration");

        JsonValue animations = root.get("animations");
        JsonIterator animationsIt = animations.iterator();
        boolean first = true;

        while (animationsIt.hasNext()) {
            JsonValue animationValue = animationsIt.next();

            String name = animationValue.getString("name");
            String frames = animationValue.getString("frames");

            Animation animation = new Animation(animationData.frameDuration,
                                                getAnimationFrames(animationData.texture, frames),
                                                getPlayMode(animationValue.getString("mode", "normal")));
            animationData.animations.put(name, animation);

            logger.info("" + fileName + " loaded animation " + name);

            if (first) {
                animationData.defaultAnimation = animation;
                first = false;
            }
        }
    } catch (Exception e) {
        logger.error("error loading file " + fileName + " " + e.getMessage());
    }
}
项目:sioncore    文件:AnimationStateDataLoader.java   
@Override
public void loadAsync(AssetManager manager, String fileName, FileHandle file, AnimationStateDataLoaderParameter parameter) {
    logger.info("loading " + fileName);

    data = new AnimationStateData(manager.get(parameter.skeletonName, SkeletonData.class));

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(file);

        float defaultBlend = root.get("defaultBlend").asFloat();

        logger.info("default blend: " + defaultBlend + "s");

        data.setDefaultMix(defaultBlend);

        JsonIterator blendIt = root.get("blends").iterator();

        while (blendIt.hasNext()) {
            JsonValue blendValue = blendIt.next();
            String from = blendValue.get("from").asString(); 
            String to = blendValue.get("to").asString();
            float duration = blendValue.get("duration").asFloat();

            data.setMix(from, to , duration);

            logger.info("blend: " + from + " -> " + to + " [" + duration + "s]");
        }
    }
    catch (Exception e) {
        logger.error("error loading " + fileName + " " + e.getMessage());
    }
}
项目:sioncore    文件:PhysicsLoader.java   
private void loadFixtureDefs(JsonValue root) {
    JsonValue fixtures = root.get("fixtures");
    JsonIterator fixturesIt = fixtures.iterator();
    int index = 0;

    while (fixturesIt.hasNext()) {
        JsonValue fixture = fixturesIt.next();

        FixtureDef fixtureDef = new FixtureDef();

        fixtureDef.density = fixture.getFloat("density", 1.0f);
        fixtureDef.restitution = fixture.getFloat("restitution", 0.0f);
        fixtureDef.friction = fixture.getFloat("friction", 1.0f);
        fixtureDef.isSensor = fixture.getBoolean("isSensor", false);
        fixtureDef.shape = loadShape(fixture);
        loadFilter(fixture, fixtureDef.filter);
        String id = fixture.getString("id", "");

        logger.info("loading fixture with id " + id);

        physicsData.fixtureNames.add(id);
        physicsData.fixtureIdx.put(id, index);
        physicsData.fixtureDefs.add(fixtureDef);

        ++index;
    }
}