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


Java JsonValue.getInt方法代码示例

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


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

示例1: readTextureDescriptor

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的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

示例2: AnimationDescription

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
public AnimationDescription(T key, JsonValue line) {
	this.key = key;
	this.startingFrame = line.getInt("start");
	this.numberOfFrames = line.getInt("count");
	this.playMode = line.getInt("mode");
	this.sounds = readSoundInfo(line.get("sounds"));
	JsonValue offset = line.get("middleOffset");
	if (offset != null) {
		middleOffsets.put(key, new Vector2(offset.getInt("x"), offset.getInt("y")));
	}
	JsonValue bounds = line.get("bounds");
	if (bounds != null) {
		for (JsonValue rectangle : bounds) {
			this.bounds.put(Integer.valueOf(rectangle.name().trim()), new Rectangle(rectangle.getInt("x"),
					rectangle.getInt("y"), rectangle.getInt("width"), rectangle.getInt("height")));
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:19,代码来源:AnimationMap.java

示例3: read

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
	if (jsonData.has("time"))
		time = jsonData.getInt("time");
	if (jsonData.get("value").isNumber())
		value = jsonData.getFloat("value");
	else
		value = new Color();
	JsonValue curveValue = jsonData.get("curve");
	JsonValue constraintsValue = curveValue.get("constraints");
	int c1, c2, c3, c4;
	c1 = constraintsValue.getInt("c1");
	c2 = constraintsValue.getInt("c2");
	c3 = constraintsValue.getInt("c3");
	c4 = constraintsValue.getInt("c4");
	curve = new Curve();
	curve.constraints.set(c1, c2, c3, c4);
	if (curveValue.has("type"))
		curve.setType(json.readValue(Type.class, curveValue.get("type")));
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:21,代码来源:Key.java

示例4: read

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
	if (jsonData.has("sortingLayerName"))
		sortingLayerName = jsonData.getString("sortingLayerName");
	if (jsonData.has("sortingOrder"))
		sortingOrder = jsonData.getInt("sortingOrder");
	if (jsonData.has("enabled"))
		enabled = jsonData.getBoolean("enabled");
	if (jsonData.has("shader")) {
		Shader shader = new Shader("");
		shader.read(json, jsonData.get("shader"));
		this.shader = shader;
	}
	if(jsonData.has("srcBlendFunction"))
		srcBlendFunction = jsonData.getInt("srcBlendFunction");
	if(jsonData.has("dstBlendFunction"))
		srcBlendFunction = jsonData.getInt("dstBlendFunction");
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:19,代码来源:Renderer.java

示例5: load

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
public static SerialArray<Tile> load(String map, HashMap<Integer, Player> players) {
    JsonValue value = reader.parse(map);
    float scale = value.getFloat("scale");
    JsonValue regions = value.get("regions");

    SerialArray<Tile> tiles = new SerialArray<>();

    for (JsonValue region : regions) {
        Color color = Color.valueOf(region.getString("color"));

        for (JsonValue tile : region.get("tiles")) {
            int x = tile.getInt("x"), y = tile.getInt("y");
            int width = tile.getInt("w"), height = tile.getInt("h");
            Tile t = new Tile(x * scale, y * scale, (int) (width * scale), (int) (height * scale), color);
            t.setRegion(region.name);
            t.setTroops(tile.getInt("troops"));

            if (tile.get("city") != null) {
                JsonValue city = tile.get("city");
                float cx = city.getInt("x") * scale, cy = city.getInt("y") * scale;
                City c = new City(cx + t.getX(), cy + t.getY(), city.getBoolean("major"));

                t.setCity(c);
            }

            if (players.get(tile.getInt("owner")) != null) {
                t.setOwner(players.get(tile.getInt("owner")));
            }

            t.setIndex(tile.getInt("index"));
            tiles.add(t);
        }
    }

    for (int i = 0; i < tiles.size; i++) {
        tiles.get(i).setContacts(tiles);
    }

    return tiles;
}
 
开发者ID:conquest,项目名称:conquest,代码行数:41,代码来源:Level.java

示例6: handleHttpResponse

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
    String result = httpResponse.getResultAsString();

    Json json = new Json();

    ArrayList list = json.fromJson(ArrayList.class, result);
    Array<LeaderBoardEntry> leaderBoardEntries = new Array<LeaderBoardEntry>();

    if (list != null) {
        for (Object entry : list) {
            if (entry != null && entry instanceof JsonValue) {
                JsonValue jsonEntry = (JsonValue) entry;

                // the reflection does not seem to work on iOS
                // LeaderBoardEntry leaderBoardEntry = json.readValue(
                //    LeaderBoardEntry.class, (JsonValue)entry);
                LeaderBoardEntry leaderBoardEntry = new LeaderBoardEntry();
                try {
                    leaderBoardEntry.name = jsonEntry.getString("name");
                    leaderBoardEntry.rank = jsonEntry.getInt("rank");
                    leaderBoardEntry.score = jsonEntry.getInt("score");
                } catch (IllegalArgumentException e) {
                    Gdx.app.log(TAG, "failed to read json: " + e.toString());
                    return;
                }

                leaderBoardEntries.add(leaderBoardEntry);
            }
        }
    }

    mListener.onSuccess(leaderBoardEntries);
}
 
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:35,代码来源:LeaderBoardController.java

示例7: read

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public Bounds read(Json json, JsonValue jsonData, Class type) {
    int width = jsonData.getInt("width");
    int height = jsonData.getInt("height");
    Bounds bounds = new Bounds(width, height);
    return bounds;
}
 
开发者ID:Benjozork,项目名称:Onyx,代码行数:8,代码来源:BoundsSerializer.java

示例8: read

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
public void read(Json json, JsonValue jsonData) 
{
	punchesLandedPrisoner = jsonData.getInt("punchesLandedPrisoner");
	punchesLandedCop = jsonData.getInt("punchesLandedCop");
	trainKillsPrisoner = jsonData.getInt("trainKillsPrisoner");
	trainKillsCop = jsonData.getInt("trainKillsCop");
	beaten = jsonData.getBoolean("beaten");
	captures = jsonData.getInt("captures");
	mapID = jsonData.getInt("mapId");
	mapCompletionTime = jsonData.getLong("mapTime");
	trainsDerailed = jsonData.getInt("trainsDerailed");
	startingPrisoners = jsonData.getInt("startingPrisoners");
	survivingPrisoners = jsonData.getInt("survivingPrisoners");
}
 
开发者ID:ChainGangChase,项目名称:cgc-game,代码行数:15,代码来源:CGCStat.java

示例9: parse

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void parse(JsonValue wheelJson) {
    WheelComponent wheelComponent = null;
    VehicleComponent vehicleComponent = nhg.entities.getComponent(parentEntity, VehicleComponent.class);

    if (vehicleComponent != null) {
        Vector3Json attachmentPointJson = new Vector3Json();
        attachmentPointJson.parse(wheelJson.get("attachmentPoint"));

        Vector3Json directionJson = new Vector3Json();
        directionJson.parse(wheelJson.get("direction"));

        Vector3Json axisJson = new Vector3Json();
        axisJson.parse(wheelJson.get("axis"));

        int wheelIndex = wheelJson.getInt("wheelIndex");

        float radius = wheelJson.getFloat("radius", 0.1f);
        float suspensionRestLength = wheelJson.getFloat("suspensionRestLength", radius * 0.3f);
        float wheelFriction = wheelJson.getFloat("friction", 5f);

        boolean frontWheel = wheelJson.getBoolean("frontWheel", false);

        wheelComponent = nhg.entities.createComponent(entity, WheelComponent.class);
        wheelComponent.wheelIndex = wheelIndex;
        wheelComponent.suspensionRestLength = suspensionRestLength;
        wheelComponent.wheelFriction = wheelFriction;
        wheelComponent.frontWheel = frontWheel;
        wheelComponent.attachmentPoint = attachmentPointJson.get();
        wheelComponent.direction = directionJson.get();
        wheelComponent.axis = axisJson.get();
        wheelComponent.vehicleComponent = vehicleComponent;
    }

    output = wheelComponent;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:37,代码来源:WheelComponentJson.java

示例10: CharacterAnimationDescription

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
public CharacterAnimationDescription(Pair<String, Orientation> key, JsonValue line) {
	super(key, line);
	this.numberOfSteps = line.getInt("numberOfSteps", 0);
	this.framesPerStep = line.getInt("framesPerStep", 0);
	this.tilesTravelledPerStep = line.getFloat("tilesTravelledPerStep", 0);
	this.hitFrame = line.getInt("hitFrame", 0);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:8,代码来源:CharacterAnimationMap.java

示例11: readAnimation

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
private void readAnimation(JsonValue line, ObjectMap<Integer, Array<AnimationDescription>> animationInfoMap) {
	int animationLineNumber = line.getInt("line");

	AnimationDescription ad = readAnimationDescription(line);

	Array<AnimationDescription> lineAnimations = animationInfoMap.get(animationLineNumber);
	if (lineAnimations == null) {
		lineAnimations = new Array<AnimationDescription>();
		animationInfoMap.put(animationLineNumber, lineAnimations);
	}

	lineAnimations.add(ad);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:14,代码来源:AnimationMap.java

示例12: read

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
	super.read(json, jsonData);
	if (jsonData.has("width"))
		width = jsonData.getFloat("width");
	if (jsonData.has("height"))
		height = jsonData.getFloat("height");
	if (jsonData.has("texture"))
		texturePath = jsonData.getString("texture");
	if (jsonData.has("srcX")) {
		useCustomSrc = true;
		srcX = jsonData.getInt("srcX");
	}
	if (jsonData.has("srcY"))
		srcY = jsonData.getInt("srcY");
	if (jsonData.has("srcWidth"))
		srcWidth = jsonData.getInt("srcWidth");
	if (jsonData.has("srcHeight"))
		srcHeight = jsonData.getInt("srcHeight");
	if (jsonData.has("originX"))
		originX = jsonData.getFloat("originX");
	if (jsonData.has("originY"))
		originY = jsonData.getFloat("originY");
	if (jsonData.has("minFilter"))
		minFilter = jsonData.getString("minFilter").equals("Linear") ? TextureFilter.Linear : TextureFilter.Nearest;
	if (jsonData.has("magFilter"))
		magFilter = jsonData.getString("magFilter").equals("Linear") ? TextureFilter.Linear : TextureFilter.Nearest;
	if (jsonData.has("tint"))
		setColor(JsonUtil.readColorFromJson(jsonData, "tint"));
	if (jsonData.has("uWrap")) {
		String uWrapStrings = jsonData.getString("uWrap");
		uWrap = uWrapStrings.equals("ClampToEdge") ? TextureWrap.ClampToEdge
			: uWrapStrings.equals("Repeat") ? TextureWrap.Repeat : TextureWrap.MirroredRepeat;
	}
	if (jsonData.has("vWrap")) {
		String vWrapStrings = jsonData.getString("vWrap");
		vWrap = vWrapStrings.equals("ClampToEdge") ? TextureWrap.ClampToEdge
			: vWrapStrings.equals("Repeat") ? TextureWrap.Repeat : TextureWrap.MirroredRepeat;
	}
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:41,代码来源:SpriteRenderer.java

示例13: read

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void read (Json json, JsonValue jsonData) {
	String layersString = jsonData.get("layers").toString();
	layersString = layersString.substring(layersString.indexOf('['));

	final String layers = layersString;
	final boolean renderAmbient = jsonData.has("renderAmbient") ? jsonData.getBoolean("renderAmbient") : true;
	final boolean renderToFramebuffer = jsonData.has("renderToFramebuffer") ? jsonData.getBoolean("renderToFramebuffer") : true;
	final Color clearColor = jsonData.has("clearColor") ? JsonUtil.readColorFromJson(jsonData, "clearColor")
		: Color.WHITE.cpy();
	final int resolutionX = jsonData.has("resolutionX") ? jsonData.getInt("resolutionX") : 512;
	final int resolutionY = jsonData.has("resolutionY") ? jsonData.getInt("resolutionY") : 512;
	final float zoom = jsonData.has("zoom") ? jsonData.getFloat("zoom") : 0.05f;
	final float viewportWidth = jsonData.has("viewportWidth") ? jsonData.getFloat("viewportWidth") : 512;
	final float viewportHeight = jsonData.has("viewportHeight") ? jsonData.getFloat("viewportHeight") : 512;

	Gdx.app.postRunnable(new Runnable() {
		@Override
		public void run () {
			camera.setLayers(new Json().fromJson(Array.class, layers));
			camera.setRenderAmbientLightColor(renderAmbient);
			camera.setRenderToFramebuffer(renderToFramebuffer);
			camera.setClearColor(clearColor);
			camera.setResolution(resolutionX, resolutionY);
			camera.zoom = zoom;
			camera.viewportWidth = viewportWidth;
			camera.viewportHeight = viewportHeight;
		}
	});
}
 
开发者ID:Quexten,项目名称:RavTech,代码行数:32,代码来源:Camera.java

示例14: checkSessionAnswer

import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
protected void checkSessionAnswer(boolean silent, String json) {
        JsonValue root = new JsonReader().parse(json);

        // was the query processed successfully=
        boolean success = root.getBoolean("success", false);

        String errorMsg = "";
        JsonValue errorObject = null;

        if (success) {
            // if the query was successful, maybe session is invalid?
            try {
                JsonValue resultObjectData = root.get("result").get("data");

                connected = resultObjectData.getBoolean("success");

// => Answer when session is invalid:
// {"success":true,"app_id":"46188:ARRyvuAv","result":{"component":"App.checkSession","data":{"success":false,
// "error":{"message":"Session, with id \"aa9f2716754951641744e7628247f54237cb2b8d8bed24\", is invalid or expired.",
// "code":104},"parameters":{}}}}

//=> Answer when session is valid:
// {"success":true,"app_id":"46188:ARRyvuAv","result":{"component":"App.checkSession","data":{"success":true,
// "session":{"id":"aa9f2716754951641744e7628247f54237cb2b8d8bed24","user":{"id":6406923,"name":"MrStahlfelge",
// "icons":{"small":"http:\/\/img.ngfiles.com\/defaults\/icon-user-smallest.gif","medium":"http:\/\/img.ngfiles
// .com\/defaults\/icon-user-smaller.gif","large":"http:\/\/img.ngfiles.com\/defaults\/icon-user.gif"},
// "url":"http:\/\/mrstahlfelge.newgrounds.com","supporter":false},"expired":false,"remember":false}}}}

                if (connected) {
                    JsonValue userData = resultObjectData.get("session").get("user");
                    userName = userData.getString("name");
                    userId = userData.getInt("id");
                } else {
                    errorMsg = "User session invalid";
                    errorObject = resultObjectData.get("error");
                }

            } catch (Throwable t) {
                Gdx.app.error(GAMESERVICE_ID, "Error checking session - could not parse user data");
            }

        } else {
//=> Answer when call is blocked:
// {"success":false,"error":{"message":"You have been making too many calls to the API and have been temporarily
// blocked. Try again in 96 seconds.","code":107},"api_version":"3.0.0","help_url":"http:\/\/www.newgrounds
// .com\/wiki\/creator-resources\/newgrounds-apis\/newgrounds-io"}

            connected = false;

            errorObject = root.get("error");
            errorMsg = "Error checking session";

        }

        if (!connected) {
            if (errorObject != null)
                errorMsg = errorMsg + ": " + errorObject.getInt("code") + "/" + errorObject.getString("message");

            Gdx.app.log(GAMESERVICE_ID, errorMsg);

            if (!silent && gsListener != null)
                gsListener.gsShowErrorToUser(IGameServiceListener.GsErrorType.errorLoginFailed, errorMsg, null);
        }

        if (gsListener != null) {
            if (connected)
                // yeah!
                gsListener.gsOnSessionActive();
            else
                // reset pending state
                gsListener.gsOnSessionInactive();
        }
    }
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:74,代码来源:NgioClient.java

示例15: update

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


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