Java Code Examples for com.badlogic.gdx.utils.JsonValue#getInt()
The following examples show how to use
com.badlogic.gdx.utils.JsonValue#getInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceManager.java From Unlucky with MIT License | 6 votes |
private void loadWorlds() { // parse worlds.json JsonValue base = jsonReader.parse(Gdx.files.internal("maps/worlds.json")); int worldIndex = 0; for (JsonValue world : base.get("worlds")) { String worldName = world.getString("name"); String shortDesc = world.getString("shortDesc"); String longDesc = world.getString("longDesc"); int numLevels = world.getInt("numLevels"); int levelIndex = 0; Level[] temp = new Level[numLevels]; // load levels for (JsonValue level : world.get("levels")) { temp[levelIndex] = new Level(worldIndex, levelIndex, level.getString("name"), level.getInt("avgLevel")); levelIndex++; } worlds.add(new World(worldName, shortDesc, longDesc, numLevels, temp)); worldIndex++; } }
Example 2
Source File: ResourceManager.java From Unlucky with MIT License | 6 votes |
private void loadItems(JsonValue itemPool, int rarity, String r) { Array<Item> rare = new Array<Item>(); for (JsonValue i : itemPool.get(r)) { int type = i.getInt("type"); if (type == 0) { rare.add(new Item(this, i.getString("name"), i.getString("desc"), rarity, i.getInt("imgIndex"), i.getInt("minLevel"), i.getInt("maxLevel"), i.getInt("hp"), i.getInt("exp"), i.getInt("sell"))); } else if (type == 1) { rare.add(new Item(this, i.getString("name"), i.getString("desc"), rarity, i.getInt("imgIndex"), i.getInt("minLevel"), i.getInt("maxLevel"), i.getInt("sell"))); } else if (type >= 2 && type <= 9) { rare.add(new Item(this, i.getString("name"), i.getString("desc"), i.getInt("type"), rarity, i.getInt("imgIndex"), i.getInt("minLevel"), i.getInt("maxLevel"), i.getInt("mhp"), i.getInt("dmg"), i.getInt("acc"), i.getInt("sell"))); } else if (type == 10) { rare.add(new Item(this, i.getString("name"), i.getString("desc"), rarity, i.getInt("imgIndex"), i.getInt("minLevel"), i.getInt("maxLevel"), i.getInt("eChance"), i.getInt("sell"))); } } items.add(rare); }
Example 3
Source File: ResourceManager.java From Unlucky with MIT License | 6 votes |
private void loadShopItems(JsonValue itemPool, int rarity, String r) { Array<ShopItem> rare = new Array<ShopItem>(); for (JsonValue i : itemPool.get(r)) { int type = i.getInt("type"); if (type == 0) { rare.add(new ShopItem(this, i.getString("name"), i.getString("desc"), rarity, i.getInt("imgIndex"), i.getInt("level"), i.getInt("hp"), i.getInt("exp"), i.getInt("sell"), i.getInt("price"))); } else if (type >= 2 && type <= 9) { rare.add(new ShopItem(this, i.getString("name"), i.getString("desc"), type, rarity, i.getInt("imgIndex"), i.getInt("level"), i.getInt("mhp"), i.getInt("dmg"), i.getInt("acc"), i.getInt("sell"), i.getInt("price"))); } else if (type == 10) { rare.add(new ShopItem(this, i.getString("name"), i.getString("desc"), rarity, i.getInt("imgIndex"), i.getInt("level"), i.getInt("eChance"), i.getInt("sell"), i.getInt("price"))); } } shopItems.add(rare); }
Example 4
Source File: FlipbookModule.java From talos with Apache License 2.0 | 5 votes |
@Override public void read (Json json, JsonValue jsonData) { super.read(json, jsonData); regionName = jsonData.getString("regionName", "fire"); rows = jsonData.getInt("rows", 1); cols = jsonData.getInt("cols", 1); duration = jsonData.getFloat("duration", 1); }
Example 5
Source File: RibbonModule.java From talos with Apache License 2.0 | 5 votes |
@Override public void read (Json json, JsonValue jsonData) { super.read(json, jsonData); detail = jsonData.getInt("details", 10); memoryDuration = jsonData.getFloat("memory", 10); RibbonRenderer renderer = (RibbonRenderer) outputValue.getDrawable(); renderer.setConfig(detail, memoryDuration); }
Example 6
Source File: NinePatchModule.java From talos with Apache License 2.0 | 5 votes |
@Override public void read (Json json, JsonValue jsonData) { super.read(json, jsonData); splits[0] = jsonData.getInt("lsplit", 0); splits[1] = jsonData.getInt("rsplit", 0); splits[2] = jsonData.getInt("tsplit", 0); splits[3] = jsonData.getInt("bsplit", 0); }
Example 7
Source File: PolylineModule.java From talos with Apache License 2.0 | 5 votes |
@Override public void read (Json json, JsonValue jsonData) { super.read(json, jsonData); pointCount = jsonData.getInt("points", 0) + 2; polylineDrawable.setCount(pointCount - 2); regionName = jsonData.getString("regionName", "fire"); }
Example 8
Source File: AttachmentPoint.java From talos with Apache License 2.0 | 5 votes |
@Override public void read(Json json, JsonValue jsonData) { attachedToSlot = jsonData.getInt("slotId", -1); type = Type.valueOf(jsonData.getString("type", Type.STATIC.name())); if(type == Type.ATTACHED) { attachmentType = AttachmentType.valueOf(jsonData.getString("attachmentType", AttachmentType.POSITION.name())); boneName = jsonData.getString("boneName"); offset = json.readValue(Vector2.class, jsonData.get("offset")); } else { JsonValue arr = jsonData.get("value"); numericalValue.set(arr.get(0).asFloat(), arr.get(1).asFloat(), arr.get(2).asFloat()); } }
Example 9
Source File: FreeTypeFontData.java From skin-composer with MIT License | 5 votes |
@Override public void read(Json json, JsonValue jsonData) { name = jsonData.getString("name"); file = jsonData.has("file") ? Gdx.files.absolute(jsonData.getString("file")) : null; previewTTF = jsonData.getString("previewTTF"); useCustomSerializer = jsonData.getBoolean("useCustomSerializer", false); size = jsonData.getInt("size", 16); mono = jsonData.getBoolean("mono"); hinting = jsonData.getString("hinting", "AutoMedium"); color = jsonData.getString("color"); gamma = jsonData.getFloat("gamma", 1.8f); renderCount = jsonData.getInt("renderCount", 2); borderWidth = jsonData.getFloat("borderWidth", 0); borderColor = jsonData.getString("borderColor"); borderStraight = jsonData.getBoolean("borderStraight", false); borderGamma = jsonData.getFloat("borderGamma", 1.8f); shadowOffsetX = jsonData.getInt("shadowOffsetX", 0); shadowOffsetY = jsonData.getInt("shadowOffsetY", 0); shadowColor = jsonData.getString("shadowColor"); spaceX = jsonData.getInt("spaceX"); spaceY = jsonData.getInt("spaceY"); characters = jsonData.getString("characters", ""); kerning = jsonData.getBoolean("kerning", true); flip = jsonData.getBoolean("flip", false); genMipMaps = jsonData.getBoolean("genMipMaps", false); minFilter = jsonData.getString("minFilter", "Nearest"); magFilter = jsonData.getString("magFilter", "Nearest"); incremental = jsonData.getBoolean("incremental"); }
Example 10
Source File: AbstractModule.java From talos with Apache License 2.0 | 4 votes |
@Override public void read (Json json, JsonValue jsonData) { index = jsonData.getInt("index"); }
Example 11
Source File: GlobalScopeModule.java From talos with Apache License 2.0 | 4 votes |
@Override public void read(Json json, JsonValue jsonData) { super.read(json, jsonData); key = jsonData.getInt("key", 0); }
Example 12
Source File: Theme.java From Klooni1010 with GNU General Public License v3.0 | 4 votes |
private Theme update(final FileHandle handle) { if (skin == null) { throw new NullPointerException("A Theme.skin must be set before updating any Theme instance"); } final JsonValue json = new JsonReader().parse(handle.readString()); name = handle.nameWithoutExtension(); displayName = json.getString("name"); price = json.getInt("price"); JsonValue colors = json.get("colors"); // Java won't allow unsigned integers, we need to use Long background = new Color((int) Long.parseLong(colors.getString("background"), 16)); foreground = new Color((int) Long.parseLong(colors.getString("foreground"), 16)); JsonValue buttonColors = colors.get("buttons"); Color[] buttons = new Color[buttonColors.size]; for (int i = 0; i < buttons.length; ++i) { buttons[i] = new Color((int) Long.parseLong(buttonColors.getString(i), 16)); if (buttonStyles[i] == null) { buttonStyles[i] = new ImageButton.ImageButtonStyle(); } // Update the style. Since every button uses an instance from this // array, the changes will appear on screen automatically. buttonStyles[i].up = skin.newDrawable("button_up", buttons[i]); buttonStyles[i].down = skin.newDrawable("button_down", buttons[i]); } currentScore = new Color((int) Long.parseLong(colors.getString("current_score"), 16)); highScore = new Color((int) Long.parseLong(colors.getString("high_score"), 16)); bonus = new Color((int) Long.parseLong(colors.getString("bonus"), 16)); bandColor = new Color((int) Long.parseLong(colors.getString("band"), 16)); textColor = new Color((int) Long.parseLong(colors.getString("text"), 16)); emptyCell = new Color((int) Long.parseLong(colors.getString("empty_cell"), 16)); JsonValue cellColors = colors.get("cells"); cells = new Color[cellColors.size]; for (int i = 0; i < cells.length; ++i) { cells[i] = new Color((int) Long.parseLong(cellColors.getString(i), 16)); } String cellTextureFile = json.getString("cell_texture"); cellTexture = SkinLoader.loadPng("cells/" + cellTextureFile); return this; }
Example 13
Source File: GDXFacebookBasic.java From gdx-facebook with Apache License 2.0 | 4 votes |
private boolean jsonHasCode200AndBody(JsonValue jsonValue) { return jsonValue.has("code") && jsonValue.getInt("code") == 200 && jsonValue.has("body"); }