當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonReader類代碼示例

本文整理匯總了Java中com.badlogic.gdx.utils.JsonReader的典型用法代碼示例。如果您正苦於以下問題:Java JsonReader類的具體用法?Java JsonReader怎麽用?Java JsonReader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JsonReader類屬於com.badlogic.gdx.utils包,在下文中一共展示了JsonReader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getScene

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
private Scene getScene(byte[] bytes) {
    Scene scene = null;

    try {
        String json = new String(bytes, "UTF-8");

        SceneJson sceneJson = new SceneJson(nhg);
        sceneJson.parse(new JsonReader().parse(json).get("scene"));

        scene = sceneJson.get();
    } catch (UnsupportedEncodingException e) {
        if (Nhg.debugLogs) e.printStackTrace();
    }

    return scene;
}
 
開發者ID:MovementSpeed,項目名稱:nhglib,代碼行數:17,代碼來源:SceneLoader.java

示例2: get

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
public int get(String resultString){
    final AtomicInteger st = new AtomicInteger(-1);
    try {
        (new JsonReader() {
            public void number(String name, long value, String stringValue) {
                super.number(name, value, stringValue);
                if (name.equals("StatusCode")) {
                    st.set((int) value);
                }
            }
        }).parse(resultString);
    } catch (Exception e) {
        LoggerFactory.getLogger(ApiStatusResultParser.class).error("Ask for Api state! Result:{}", resultString);
        e.printStackTrace();
    }
    return st.get();
}
 
開發者ID:Longri,項目名稱:cachebox3.0,代碼行數:18,代碼來源:ApiStatusResultParser.java

示例3: readTextureDescriptor

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
public ObjectMap<Integer, Array<AnimationDescription>> readTextureDescriptor(FileHandle textureDescriptor)
		throws IOException {

	JsonValue descriptor = new JsonReader().parse(textureDescriptor);

	JsonValue frame = descriptor.get("frame");
	frameWidth = frame.getInt("width");
	frameHeight = frame.getInt("height");
	frameDuration = 1 / frame.getFloat("fps");

	JsonValue offset = descriptor.get("middleOffset");
	middleOffset = new Vector2(offset.getInt("x", 0), offset.getInt("y", 0));
	middleOffsets = new ObjectMap<T, Vector2>();

	JsonValue object = descriptor.get("object");
	objectWidth = object.getInt("width");
	objectHeight = object.getInt("height");

	ObjectMap<Integer, Array<AnimationDescription>> returnValue = new ObjectMap<Integer, Array<AnimationDescription>>();
	for (JsonValue animation : descriptor.get("animations")) {
		readAnimation(animation, returnValue);
	}
	return returnValue;
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:25,代碼來源:AnimationMap.java

示例4: undo

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
@Override
public void undo () {
	JsonValue jsonData = new JsonReader().parse(gameComponent);
	Json json = new Json();
	GameObject tempObject = new GameObject();
	tempObject.readValue(json, jsonData);
	GameComponent toAddComponent = tempObject.getComponentByName(componentType);
	tempObject.getComponents().removeValue(tempObject.getComponentByName(componentType), true);
	tempObject.destroy();
	if (pathToComponent.lastIndexOf('/') == 0) {
		toAddComponent.setParent(null);
		RavTech.currentScene.addGameObject((GameObject)toAddComponent);
	} else {
		GameObject component = (GameObject)GameObjectTraverseUtil
			.gameComponentFromPath(pathToComponent.substring(0, pathToComponent.lastIndexOf('/')));
		toAddComponent.setParent(component);
		component.addComponent(toAddComponent);
	}
}
 
開發者ID:Quexten,項目名稱:RavTech,代碼行數:20,代碼來源:RemoveChangeable.java

示例5: redo

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
@Override
public void redo () {
	GameComponent parent = GameObjectTraverseUtil.gameComponentFromPath(pathToComponent);
	JsonValue jsonData = new JsonReader().parse(gameComponent);
	Json json = new Json();
	if (parent != null) {
		((GameObject)parent).readValue(json, jsonData);
		removePath = GameObjectTraverseUtil
			.pathFromGameComponent(((GameObject)parent).getComponents().get(((GameObject)parent).getComponents().size - 1));
	} else {
		GameObject object = new GameObject();
		object.readValue(json, jsonData);
		GameObject newObject = (GameObject)object.getComponents().get(1);
		newObject.setParent(null);
		removePath = GameObjectTraverseUtil.pathFromGameComponent(newObject);
		RavTech.currentScene.addGameObject(newObject);
	}
	componentType = jsonData.getString("componenttype");
}
 
開發者ID:Quexten,項目名稱:RavTech,代碼行數:20,代碼來源:CreateChangeable.java

示例6: SimulationRunner

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
public SimulationRunner() {
    logger.info("Loading models");
    ModelBuilder builder = new ModelBuilder();
    models.put("box", builder.createBox(5f, 5f, 5f,
            new Material(ColorAttribute.createDiffuse(new Color(0.8f, 0f, 0f, 0f))),
            VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal));

    G3dModelLoader loader = new G3dModelLoader(new JsonReader());
    models.put("hub", loader.loadModel(Gdx.files.internal("data/hubreal.g3dj")));
    models.put("rim", loader.loadModel(Gdx.files.internal("data/rimreal.g3dj")));
    models.put("spoke", loader.loadModel(Gdx.files.internal("data/spoke.g3dj")));


    Bullet.init();
    logger.info("Initialized Bullet");
}
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:17,代碼來源:SimulationRunner.java

示例7: create

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
@Override
public void create () {
	super.create();

	ModelLoader g3djLoader = new G3dModelLoader(new JsonReader());
	model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj"));
	disposables.add(model);

	importer = new MyImporter((btDynamicsWorld)world.collisionWorld);
	importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet"));

	camera.position.set(10f, 15f, 20f);
	camera.up.set(0, 1, 0);
	camera.lookAt(-10, 8, 0);
	camera.update();
}
 
開發者ID:Matsemann,項目名稱:eamaster,代碼行數:17,代碼來源:ImportTest.java

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: AssetManager

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
/** Creates a new AssetManager with all default loaders. */
public AssetManager (FileHandleResolver resolver) {
	setLoader(BitmapFont.class, new BitmapFontLoader(resolver));
	setLoader(Music.class, new MusicLoader(resolver));
	setLoader(Pixmap.class, new PixmapLoader(resolver));
	setLoader(Sound.class, new SoundLoader(resolver));
	setLoader(TextureAtlas.class, new TextureAtlasLoader(resolver));
	setLoader(Texture.class, new TextureLoader(resolver));
	setLoader(Skin.class, new SkinLoader(resolver));
	setLoader(ParticleEffect.class, new ParticleEffectLoader(resolver));
	setLoader(PolygonRegion.class, new PolygonRegionLoader(resolver));
	setLoader(I18NBundle.class, new I18NBundleLoader(resolver));
	setLoader(Model.class, ".g3dj", new G3dModelLoader(new JsonReader(), resolver));
	setLoader(Model.class, ".g3db", new G3dModelLoader(new UBJsonReader(), resolver));
	setLoader(Model.class, ".obj", new ObjLoader(resolver));
	executor = new AsyncExecutor(1);
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:18,代碼來源:AssetManager.java

示例14: 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

示例15: parseSuccessFromResponse

import com.badlogic.gdx.utils.JsonReader; //導入依賴的package包/類
/**
 * Helper method when just interested if GameJolt request was successful
 */
protected boolean parseSuccessFromResponse(String json) {
    JsonValue response = null;
    boolean success;
    try {
        response = new JsonReader().parse(json).get("response");
        success = response != null && response.getBoolean("success");
    } catch (Throwable t) {
        Gdx.app.error(GAMESERVICE_ID, "Cannot parse GameJolt response: " + json, t);
        success = false;
    }
    return success;
}
 
開發者ID:MrStahlfelge,項目名稱:gdx-gamesvcs,代碼行數:16,代碼來源:GameJoltClient.java


注:本文中的com.badlogic.gdx.utils.JsonReader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。