当前位置: 首页>>代码示例>>Java>>正文


Java JsonReader.parse方法代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.JsonReader.parse方法的典型用法代码示例。如果您正苦于以下问题:Java JsonReader.parse方法的具体用法?Java JsonReader.parse怎么用?Java JsonReader.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.utils.JsonReader的用法示例。


在下文中一共展示了JsonReader.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: AliasManager

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
public AliasManager(Database.SectionAccessor aliasStorage) {
	JsonReader reader = new JsonReader();
	JsonValue value = aliasStorage.root;

	if (value.size == 0) {
		// probably empty
		return;
	}

	JsonValue aliases = reader.parse(value.asString());
	JsonValue node = aliases.child;
	while (node != null) {
		put(node.name, node.asString());
		node = node.next;
	}
}
 
开发者ID:Namek,项目名称:TheConsole_POC,代码行数:17,代码来源:AliasManager.java

示例2: loadArchetypes

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:16,代码来源:EntityFactory.java

示例3: ParticleEffectPools

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
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);
	}
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:29,代码来源:ParticleEffectPools.java

示例4: loadGroups

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
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());
//		}
	}
 
开发者ID:saltares,项目名称:sioncore,代码行数:41,代码来源:Assets.java

示例5: loadMaterialsFile

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
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());
	}
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:39,代码来源:MapBodyManager.java

示例6: convert

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
/** <p>
 * Convert a text JSON file into binary JSON. The new file will be saved in the same folder as the original one with the
 * {@code gd3b} extension.
 * </p>
 * 
 * @param g3djFile Handle to the original G3DJ file.
 * @param overwrite If {@code true} the new file will overwrite any previous file with the same name. Otherwise append a
 *           counter at the end of the file name to make it unique.
 * @throws IOException If there's an exception while reading the input file or writing the output file. */
public void convert (FileHandle g3djFile, boolean overwrite) throws IOException {
	FileHandle newFile = new FileHandle(g3djFile.pathWithoutExtension() + ".g3db");
	int noOverwriteCounter = 0;
	while (!overwrite && newFile.exists()) {
		newFile = new FileHandle(g3djFile.pathWithoutExtension() + "(" + (++noOverwriteCounter) + ").g3db");
	}

	OutputStream fileOutputStream = newFile.write(false);
	UBJsonWriter writer = new UBJsonWriter(fileOutputStream);
	JsonReader reader = new JsonReader();

	try {
		JsonValue root = reader.parse(g3djFile);
		writeObject(root, writer);

	} finally {
		writer.close();
	}
}
 
开发者ID:Dancovich,项目名称:libgdx_g3db_converter,代码行数:29,代码来源:G3DBConverter.java

示例7: createMenu

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
private void createMenu() {
    root = new Table();
    root.setFillParent(true);
    stage.addActor(root);
    
    FileHandle fileHandle = Gdx.files.local(Core.DATA_PATH + "/data.json");
    JsonReader reader = new JsonReader();
    JsonValue val = reader.parse(fileHandle);
    
    Label title = new Label(val.getString("title"), skin, "title");
    root.add(title).padTop(50.0f).padBottom(75.0f);
    
    root.row();
    BouncingImage image = new BouncingImage(getCharacter());
    root.add(image);
    
    root.row();
    ImageButton imageButton = new  ImageButton(skin, "play");
    root.add(imageButton).padTop(75.0f).expandY().top();
    imageButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            getCore().getAssetManager().get(Core.DATA_PATH + "/sfx/jump.wav", Sound.class).play();
            showCharacterDialog();
        }
    });
}
 
开发者ID:raeleus,项目名称:bobbybird,代码行数:28,代码来源:MenuState.java

示例8: loadData

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
private void loadData(String fileName, FileHandle file) {		
	logger.info("loading " + fileName);
	
	try {
		JsonReader reader = new JsonReader();
		JsonValue root = reader.parse(file);
		
		loadBodyDef(root);
		loadMassData(root);
		loadFixtureDefs(root);
		
	} catch (Exception e) {
		logger.error("error loading " + fileName + "\n" + e.getStackTrace());
	}
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:16,代码来源:PhysicsDataLoader.java

示例9: loadAsync

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
@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());
	}
}
 
开发者ID:saltares,项目名称:libgdxjam,代码行数:34,代码来源:AnimationStateDataLoader.java

示例10: setGetJsonValue

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
@Test
public void setGetJsonValue() {
    JsonReader writer = new JsonReader();
    JsonValue value = writer.parse("{testValue:2}");
    fixture.setJsonValue(value);
    assertEquals(value, fixture.getJsonValue());
}
 
开发者ID:TomGrill,项目名称:gdx-facebook,代码行数:8,代码来源:JsonResultUnitTests.java

示例11: constructorWithJsonValue

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
@Test
public void constructorWithJsonValue() {
    JsonReader writer = new JsonReader();
    JsonValue value = writer.parse("{testValue:5}");
    fixture = new JsonResult(value);
    assertEquals(value, fixture.getJsonValue());

    assertTrue(fixture.getJsonValue().has("testValue"));
    assertEquals(5, fixture.getJsonValue().getInt("testValue"));
}
 
开发者ID:TomGrill,项目名称:gdx-facebook,代码行数:11,代码来源:JsonResultUnitTests.java

示例12: load

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
public Scene load(String name) {
    final JsonReader reader = new JsonReader();
    final JsonValue json = reader.parse(root.child(name));

    Scene scene = new Scene();
    scene.setId(json.getInt(JsonScene.ID));
    scene.setName(json.getString(JsonScene.NAME));

    // game objects
    for(JsonValue go : json.get(JsonScene.GAME_OBJECTS)) {
        scene.sceneGraph.addGameObject(convertGameObject(scene.sceneGraph, go));
    }

    return scene;
}
 
开发者ID:mbrlabs,项目名称:Mundus,代码行数:16,代码来源:SceneLoader.java

示例13: loadAsync

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
/**
 * 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());
	}
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:47,代码来源:SpriteAnimationLoader.java

示例14: loadData

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
private void loadData(String fileName, FileHandle file) {
	logger.info("loading " + fileName);
	
	try {
		JsonReader reader = new JsonReader();
		JsonValue root = reader.parse(file);
		
		loadBodyDef(root);
		loadMassData(root);
		loadFixtureDefs(root);
		
	} catch (Exception e) {
		logger.error("error loading " + fileName + " " + e.getMessage());
	}
}
 
开发者ID:saltares,项目名称:sioncore,代码行数:16,代码来源:PhysicsLoader.java

示例15: loadData

import com.badlogic.gdx.utils.JsonReader; //导入方法依赖的package包/类
@Override
public Array<? extends SceneGraphNode> loadData() {
    Array<T> bodies = new Array<T>();

    try {
        JsonReader json = new JsonReader();
        for (String filePath : filePaths) {
            FileHandle file = Gdx.files.internal(filePath);
            JsonValue model = json.parse(file.read());
            JsonValue child = model.get("objects").child;
            int size = 0;
            while (child != null) {
                size++;
                String clazzName = child.getString("impl");

                Class<Object> clazz = (Class<Object>) ClassReflection.forName(clazzName);

                // Convert to object and add to list
                T object = (T) convertJsonToObject(child, clazz);

                bodies.add(object);

                child = child.next;
            }
            Logger.info(this.getClass().getSimpleName(), I18n.bundle.format("notif.nodeloader", size, filePath));
        }

    } catch (Exception e) {
        Logger.error(e);
    }

    return bodies;
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:34,代码来源:JsonLoader.java


注:本文中的com.badlogic.gdx.utils.JsonReader.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。