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


Java JsonValue类代码示例

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


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

示例1: submitToLeaderboard

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public boolean submitToLeaderboard(String leaderboardId, long score, String tag) {
    if (boardMapper == null) {
        Gdx.app.log(GAMESERVICE_ID, "Cannot post score: No mapper for leader board ids provided.");
        return false;
    }

    Integer boardId = boardMapper.mapToGsId(leaderboardId);

    // no board available or not connected
    if (boardId == null || !isSessionActive())
        return false;

    JsonValue parameters = new JsonValue(JsonValue.ValueType.object);
    parameters.addChild("id", new JsonValue(boardId));
    parameters.addChild("value", new JsonValue(score));
    if (tag != null)
        parameters.addChild("tag", new JsonValue(tag));

    sendToGateway("ScoreBoard.postScore", parameters, null);

    return true;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:24,代码来源:NgioClient.java

示例2: submitEvent

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public boolean submitEvent(String eventId, int increment) {
    // incrementing is not supported by Newgrounds, so we ignore the param

    if (!initialized) {
        Gdx.app.error(GAMESERVICE_ID, "Cannot submit event before initialize() is called.");
        return false;
    }

    if (eventHostId == null) {
        Gdx.app.log(GAMESERVICE_ID, "Cannot post event: No host id for logging events provided.");
        return false;
    }

    JsonValue parameters = new JsonValue(JsonValue.ValueType.object);
    parameters.addChild("event_name", new JsonValue(eventId));
    parameters.addChild("host", new JsonValue(eventHostId));

    sendToGateway("Event.logEvent", parameters, null);

    return true;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:23,代码来源:NgioClient.java

示例3: unlockAchievement

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public boolean unlockAchievement(String achievementId) {
    if (medalMapper == null) {
        Gdx.app.log(GAMESERVICE_ID, "Cannot unlock achievmenet: No mapper for achievement ids provided.");
        return false;
    }

    Integer medalId = medalMapper.mapToGsId(achievementId);

    // no board available or not connected
    if (medalId == null)
        return false;

    if (!isSessionActive())
        return false;

    JsonValue parameters = new JsonValue(JsonValue.ValueType.object);
    parameters.addChild("id", new JsonValue(medalId));

    sendToGateway("Medal.unlock", parameters, null);

    return true;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:24,代码来源:NgioClient.java

示例4: fromJson

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
protected static GjScoreboardEntry fromJson(JsonValue json, int rank, String currentPlayer) {
    GjScoreboardEntry gje = new GjScoreboardEntry();
    gje.rank = String.valueOf(rank);
    gje.score = json.getString("score");
    gje.sort = json.getLong("sort");
    gje.tag = json.getString("extra_data");
    String userId = json.getString("user_id");

    if (userId != null && !userId.isEmpty()) {
        gje.userId = userId;
        gje.displayName = json.getString("user");
        gje.currentPlayer = (currentPlayer != null && currentPlayer.equalsIgnoreCase(gje.displayName));
    } else
        gje.displayName = json.getString("guest");

    gje.stored = json.getString("stored");

    return gje;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-gamesvcs,代码行数:20,代码来源:GjScoreboardEntry.java

示例5: toJson

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
/**
 * Save mapping for this controller instance
 *
 * @return
 */
public JsonValue toJson() {
    JsonValue json = new JsonValue(JsonValue.ValueType.array);
    for (MappedInput mapping : mappingsByConfigured.values()) {
        JsonValue jsonmaping = new JsonValue(JsonValue.ValueType.object);
        jsonmaping.addChild("confId", new JsonValue(mapping.configuredInputId));
        if (mapping.controllerInput instanceof ControllerAxis)
            jsonmaping.addChild("axis", new JsonValue(((ControllerAxis) mapping.controllerInput).axisIndex));
        else if (mapping.controllerInput instanceof ControllerButton) {
            jsonmaping.addChild("button",
                    new JsonValue(((ControllerButton) mapping.controllerInput).buttonIndex));
            if (mapping.secondButtonForAxis != null)
                jsonmaping.addChild("buttonR", new JsonValue((mapping.secondButtonForAxis.buttonIndex)));
        } else if (mapping.controllerInput instanceof ControllerPovButton) {
            jsonmaping.addChild("pov", new JsonValue(((ControllerPovButton) mapping.controllerInput).povIndex));
            jsonmaping.addChild("vertical",
                    new JsonValue(((ControllerPovButton) mapping.controllerInput).povDirectionVertical));
        }
        json.addChild(jsonmaping);
    }
    return json;
}
 
开发者ID:MrStahlfelge,项目名称:gdx-controllerutils,代码行数:27,代码来源:ControllerMappings.java

示例6: readVertices

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
private void readVertices (JsonValue map, VertexAttachment attachment, int verticesLength) {
	attachment.setWorldVerticesLength(verticesLength);
	float[] vertices = map.require("vertices").asFloatArray();
	if (verticesLength == vertices.length) {
		if (scale != 1) {
			for (int i = 0, n = vertices.length; i < n; i++)
				vertices[i] *= scale;
		}
		attachment.setVertices(vertices);
		return;
	}
	FloatArray weights = new FloatArray(verticesLength * 3 * 3);
	IntArray bones = new IntArray(verticesLength * 3);
	for (int i = 0, n = vertices.length; i < n;) {
		int boneCount = (int)vertices[i++];
		bones.add(boneCount);
		for (int nn = i + boneCount * 4; i < nn; i += 4) {
			bones.add((int)vertices[i]);
			weights.add(vertices[i + 1] * scale);
			weights.add(vertices[i + 2] * scale);
			weights.add(vertices[i + 3]);
		}
	}
	attachment.setBones(bones.toArray());
	attachment.setVertices(weights.toArray());
}
 
开发者ID:laurencegw,项目名称:jenjin,代码行数:27,代码来源:SkeletonJson.java

示例7: parse

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public void parse(JsonValue jsonValue) {
    JsonValue contextsJson = jsonValue.get("contexts");

    for (JsonValue contextJson : contextsJson) {
        String name = contextJson.getString("name");
        JsonValue inputsJson = contextJson.get("inputs");

        InputContext inputContext = new InputContext(name);

        for (JsonValue inputJson : inputsJson) {
            //inputContext.addInput(inputFromJson(inputJson));
        }

        inputContexts.add(inputContext);
    }
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:18,代码来源:InputJson.java

示例8: parse

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public void parse(JsonValue jsonValue) {
    String alias = jsonValue.getString("alias");
    String source = jsonValue.getString("source");
    String classString = jsonValue.getString("classAlias");

    String dependenciesPath = jsonValue.getString(
            "dependenciesPath",
            getDefaultDependenciesPath(source));

    if (!dependenciesPath.endsWith("/")) {
        dependenciesPath += "/";
    }

    Class assetClass = SceneUtils.assetClassFromAlias(classString);

    output = new Asset(alias, source, assetClass);
    output.dependenciesPath = dependenciesPath;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:20,代码来源:AssetJson.java

示例9: stickConfigurationFromJson

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
private StickConfiguration stickConfigurationFromJson(JsonValue stickConfigurationJson) {
    boolean invertHorizontalAxis = stickConfigurationJson.getBoolean("invertHorizontalAxis");
    boolean invertVerticalAxis = stickConfigurationJson.getBoolean("invertVerticalAxis");

    float deadZoneRadius = stickConfigurationJson.getFloat("deadZoneRadius");
    float horizontalSensitivity = stickConfigurationJson.getFloat("horizontalSensitivity");
    float verticalSensitivity = stickConfigurationJson.getFloat("verticalSensitivity");

    StickConfiguration stickConfiguration = new StickConfiguration();
    stickConfiguration.setInvertHorizontalAxis(invertHorizontalAxis);
    stickConfiguration.setInvertVerticalAxis(invertVerticalAxis);
    stickConfiguration.setDeadZoneRadius(deadZoneRadius);
    stickConfiguration.setHorizontalSensitivity(horizontalSensitivity);
    stickConfiguration.setVerticalSensitivity(verticalSensitivity);

    return stickConfiguration;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:18,代码来源:InputConfigurationsJson.java

示例10: parse

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public void parse(JsonValue jsonValue) {
    ModelComponent modelComponent =
            nhg.entities.createComponent(entity, ModelComponent.class);

    String type = jsonValue.getString("graphicsType");
    String asset = jsonValue.getString("asset", "");

    boolean enabled = jsonValue.getBoolean("enabled", true);

    JsonValue materialsJson = jsonValue.get("materials");

    if (materialsJson != null) {
        for (JsonValue mat : materialsJson) {
            PbrMaterialJson pbrMaterialJson = new PbrMaterialJson();
            pbrMaterialJson.parse(mat);

            modelComponent.pbrMaterials.add(pbrMaterialJson.get());
        }
    }

    modelComponent.type = ModelComponent.Type.fromString(type);
    modelComponent.asset = asset;
    modelComponent.enabled = enabled;
    output = modelComponent;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:27,代码来源:ModelComponentJson.java

示例11: fromJson

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
public void fromJson(JsonValue jsonValue) {
    InputJson inputJson = new InputJson();
    inputJson.parse(jsonValue);

    for (InputContext inputContext : inputJson.get()) {
        addContext(inputContext);
    }

    InputConfigurationsJson configurationsJson = new InputConfigurationsJson();
    configurationsJson.parse(jsonValue);
    config = configurationsJson.get();

    mapKeyInputs();
    mapStickInputs();
    mapPointerInputs();
    mapMouseInputs();
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:18,代码来源:InputHandlerOld.java

示例12: ParticleEffect

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
public ParticleEffect(JsonValue json) {
    elapsed = 0;

    Vector2Pool vector2Pool = Vector2Pool.getInstance();
    position = vector2Pool.obtain(0, 0);
    sizeRange = vector2Pool.obtain(0, 0);
    durationRange = vector2Pool.obtain(0, 0);
    particlesRange = vector2Pool.obtain(0, 0);
    xOffsetRange = vector2Pool.obtain(0, 0);
    yOffsetRange = vector2Pool.obtain(0, 0);
    vxRange = vector2Pool.obtain(0, 0);
    vyRange = vector2Pool.obtain(0, 0);
    velocitySplits = vector2Pool.obtain(0, 0);
    angularVelocityRange = vector2Pool.obtain(0, 0);
    redRange = vector2Pool.obtain(0, 0);
    blueRange = vector2Pool.obtain(0, 0);
    greenRange = vector2Pool.obtain(0, 0);
    alphaRange = vector2Pool.obtain(0, 0);

    modifiers = new Array<ParticleModifier>();
    particles = new Array<Particle>();
    sprites = new Array<Sprite>();

    load(json);
}
 
开发者ID:alexschimpf,项目名称:joe,代码行数:26,代码来源:ParticleEffect.java

示例13: read

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public ScaleFactorModel read(Json json, JsonValue jsonData, Class type) {
    String suffix = "";
    float factor = 1f;

    JsonValue.JsonIterator iterator = jsonData.iterator();
    while (iterator.hasNext()) {
        JsonValue value = iterator.next();
        switch (value.name) {
            case "suffix":
                suffix = value.asString();
                break;
            case "factor":
                factor = value.asFloat();
                break;
        }
    }
    return new ScaleFactorModel(suffix, factor);
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:20,代码来源:ScaleFactorJsonSerializer.java

示例14: read

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public void read(Json json, JsonValue jsonValue) {
    try {
        name = jsonValue.getString("name");
        optional = jsonValue.getBoolean("optional");
        if (jsonValue.get("value").isNumber()) {
            type = Float.TYPE;
            value = Double.parseDouble(jsonValue.getString("value"));
        } else {
            type = ClassReflection.forName(jsonValue.getString("type"));
            if (jsonValue.get("value").isNull()) {
                value = null;
            } else {
                value = jsonValue.getString("value");
            }
        }
    } catch (ReflectionException ex) {
        Gdx.app.error(getClass().toString(), "Error reading from serialized object" , ex);
        DialogFactory.showDialogErrorStatic("Read Error...","Error reading from serialized object.\n\nOpen log?");
    }
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:22,代码来源:StyleProperty.java

示例15: read

import com.badlogic.gdx.utils.JsonValue; //导入依赖的package包/类
@Override
public void read(Json json, JsonValue jsonData) {
    try {
        colors = json.readValue("colors", Array.class, jsonData);
        fonts = json.readValue("fonts", Array.class, jsonData);
        classStyleMap = new OrderedMap<>();
        for (JsonValue data : jsonData.get("classStyleMap").iterator()) {
            classStyleMap.put(ClassReflection.forName(data.name), json.readValue(Array.class, data));
        }
        for (Array<StyleData> styleDatas : classStyleMap.values()) {
            for (StyleData styleData : styleDatas) {
                styleData.jsonData = this;
            }
        }
        customClasses = json.readValue("customClasses", Array.class, CustomClass.class, new Array<>(), jsonData);
        for (CustomClass customClass : customClasses) {
            customClass.setMain(main);
        }
    } catch (ReflectionException e) {
        Gdx.app.log(getClass().getName(), "Error parsing json data during file read", e);
        main.getDialogFactory().showDialogError("Error while reading file...", "Error while attempting to read save file.\nPlease ensure that file is not corrupted.\n\nOpen error log?");
    }
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:24,代码来源:JsonData.java


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