本文整理汇总了Java中com.badlogic.gdx.utils.JsonValue.has方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.has方法的具体用法?Java JsonValue.has怎么用?Java JsonValue.has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.JsonValue
的用法示例。
在下文中一共展示了JsonValue.has方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseConfiguration
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
private void parseConfiguration(String parentType, JsonValue root) {
String type = root.name;
if (type.equals("")) {
throw new InvalidConfigException(filename, "type", "null");
}
Properties parentProperties = null;
if (parentType != null) {
parentProperties = typePropertiesMap.get(parentType);
}
Properties properties = new Properties(parentProperties);
addCustomProperties(properties, root);
typePropertiesMap.put(type, properties);
if (root.has("children")) {
for (JsonValue child : root.get("children")) {
parseConfiguration(type, child);
}
}
}
示例2: 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")));
}
示例3: 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");
}
示例4: read
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
super.read(json, jsonData);
if (jsonData.has("path"))
path = jsonData.getString("path");
if (jsonData.has("text"))
text = jsonData.getString("text");
if (jsonData.has("centerText"))
centered = jsonData.getBoolean("centerText");
if (jsonData.has("flipped"))
flipped = jsonData.getBoolean("flipped");
if (jsonData.has("xScale"))
xScale = jsonData.getFloat("xScale");
if (jsonData.has("yScale"))
yScale = jsonData.getFloat("yScale");
if (jsonData.has("tint"))
tint = JsonUtil.readColorFromJson(jsonData, "tint");
}
示例5: load
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
protected void load(JsonValue json) {
if (json.has("loop_delay")) {
loopDelay = json.getFloat("loop_delay");
}
if (json.has("textures")) {
loadSprites(json.get("textures").asStringArray());
}
if (json.has("ranges")) {
loadRanges(json.get("ranges"));
}
if (json.has("modifiers")) {
loadModifiers(json.get("modifiers"));
}
}
示例6: loadRanges
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
protected void loadRanges(JsonValue root) {
if (root.has("duration")) {
durationRange.set(ConversionUtils.toVector2(root.get("duration")));
}
if (root.has("num_particles")) {
particlesRange.set(ConversionUtils.toVector2(root.get("num_particles")));
}
if (root.has("position_offset")) {
Vector2 minOffset = ConversionUtils.toVector2(root.get("position_offset").get(0));
Vector2 maxOffset = ConversionUtils.toVector2(root.get("position_offset").get(1));
xOffsetRange.set(minOffset.x, maxOffset.x);
yOffsetRange.set(minOffset.y, maxOffset.y);
}
if (root.has("angular_velocity")) {
angularVelocityRange.set(ConversionUtils.toVector2(root.get("angular_velocity")));
}
if (root.has("color")) {
Color minColor = ConversionUtils.toColor(root.get("color").get(0));
Color maxColor = ConversionUtils.toColor(root.get("color").get(1));
redRange.set(minColor.r, maxColor.r);
greenRange.set(minColor.g, maxColor.g);
blueRange.set(minColor.b, maxColor.b);
alphaRange.set(minColor.a, maxColor.a);
}
if (root.has("velocity")) {
JsonValue velocityRoot = root.get("velocity");
Vector2 minVelocity = ConversionUtils.toVector2(velocityRoot.get("range").get(0));
Vector2 maxVelocity = ConversionUtils.toVector2(velocityRoot.get("range").get(1));
vxRange.set(minVelocity.x, maxVelocity.x);
vyRange.set(minVelocity.y, maxVelocity.y);
velocitySplits.set(ConversionUtils.toVector2(velocityRoot.get("splits")));
}
}
示例7: load
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
protected void load(JsonValue json) {
if (json.has("start")) {
startColor = ConversionUtils.toColor(json.get("start"));
}
endColor = ConversionUtils.toColor(json.get("end"));
}
示例8: read
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
for (int i = 0; i < jsonData.get("timelines").size; i++) {
Timeline timeline = new Timeline();
timeline.animator = animator;
timeline.read(json, jsonData.get("timelines").get(i));
timeline.animation = this;
timelines.add(timeline);
}
if (jsonData.has("animationLength"))
setLength(jsonData.getInt("animationLength"));
}
示例9: read
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
this.name = jsonData.getString("name");
if (jsonData.has("vertexShader")) {
this.individualShaders = true;
this.vertexShader = jsonData.getString("vertexShader");
this.fragmentShader = jsonData.getString("fragmentShader");
Gdx.app.postRunnable(new Runnable() {
@Override
public void run () {
Debug.log("load", Shader.this.fragmentShader);
Shader.this.manager.add(Shader.this.name, RavTech.files.getAssetHandle(vertexShader),
RavTech.files.getAssetHandle(fragmentShader));
}
});
}
String textureString = jsonData.get("textures").toString();
textureString = textureString.substring(textureString.indexOf('{'));
this.textures = json.fromJson(ObjectMap.class, String.class, textureString);
Gdx.app.postRunnable(new Runnable() {
@Override
public void run () {
Entries<String, String> entries = Shader.this.textures.iterator();
while (entries.hasNext) {
Entry<String, String> entry = entries.next();
if (!entry.value.endsWith(".framebuffer") && !RavTech.files.isLoaded(entry.value)) {
RavTech.files.loadAsset(entry.value, Texture.class, true);
((Texture)RavTech.files.getAsset(entry.value, Texture.class)).setFilter(TextureFilter.Linear, TextureFilter.Linear);
}
Shader.this.textures.put(entry.key, entry.value);
}
}
});
}
示例10: 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;
}
}
示例11: read
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
if (jsonData.has("type"))
setLightType(jsonData.getString("type").equals(LightType.ChainLight.toString()) ? LightType.ChainLight
: jsonData.getString("type").equals(LightType.ConeLight.toString()) ? LightType.ConeLight
: jsonData.getString("type").equals(LightType.DirectionalLight.toString()) ? LightType.DirectionalLight
: jsonData.getString("type").equals(LightType.PointLight.toString()) ? LightType.PointLight
: LightType.ConeLight);
setAngle(jsonData.has("angle") ? jsonData.getFloat("angle") : 90);
setColor(JsonUtil.readColorFromJson(jsonData, "color"));
setDistance(jsonData.has("distance") ? jsonData.getFloat("distance") : 10);
setRayCount(jsonData.has("rayCount") ? jsonData.getInt("rayCount") : 360);
setSoft(jsonData.has("isSoft") ? jsonData.getBoolean("isSoft") : true);
setSoftnessLength(jsonData.has("softnessLength") ? jsonData.getFloat("softnessLength") : 2);
}
示例12: read
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void read (Json json, JsonValue jsonData) {
super.read(json, jsonData);
String[] variables = getVariableNames();
for (int i = 0; i < variables.length; i++)
if (jsonData.has(variables[i]))
setVariable(i, jsonData.getString(variables[i]));
}
示例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;
}
});
}
示例14: parse
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void parse(JsonValue jsonValue) {
String id = jsonValue.getString("id");
boolean attachToParent = jsonValue.getBoolean("attachToParent", true);
int entity;
if (attachToParent) {
entity = sceneGraph.addSceneEntity(id, parentEntity);
} else {
entity = sceneGraph.addSceneEntity(id);
}
JsonValue componentsJson = jsonValue.get("components");
for (JsonValue componentJsonValue : componentsJson) {
String type = componentJsonValue.getString("type");
ComponentJson componentJson = SceneUtils.componentJsonFromType(type);
if (componentJson != null) {
componentJson.parentEntity = parentEntity;
componentJson.entity = entity;
componentJson.nhg = nhg;
componentJson.sceneGraph = sceneGraph;
componentJson.parse(componentJsonValue);
}
}
JsonValue entitiesJson = jsonValue.get("entities");
if (entitiesJson != null) {
for (JsonValue entityJsonValue : entitiesJson) {
EntityJson entityJson = new EntityJson(nhg);
entityJson.sceneGraph = sceneGraph;
entityJson.parentEntity = entity;
entityJson.parse(entityJsonValue);
}
}
String parentInternalNodeId = jsonValue.getString("parentInternalNodeId", null);
TransformJson transformJson = new TransformJson();
if (jsonValue.has("transform")) {
transformJson.parse(jsonValue.get("transform"));
NodeComponent nodeComponent = nhg.entities.getComponent(entity, NodeComponent.class);
nodeComponent.parentInternalNodeId = parentInternalNodeId;
nodeComponent.setTransform(
transformJson.position,
transformJson.rotation,
transformJson.scale);
}
output = entity;
}
示例15: parse
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void parse(JsonValue jsonValue) {
VehicleComponent vehicleComponent = nhg.entities.createComponent(entity, VehicleComponent.class);
// Shape
ShapeJson shapeJson = new ShapeJson();
if (jsonValue.has("shape")) {
shapeJson.parse(jsonValue.get("shape"));
}
// Vehicle tuning
VehicleTuningJson vehicleTuningJson = new VehicleTuningJson();
if (jsonValue.has("vehicleTuning")) {
vehicleTuningJson.parse(jsonValue.get("vehicleTuning"));
}
float mass = jsonValue.getFloat("mass", 1f);
float friction = jsonValue.getFloat("friction", 5f);
float restitution = jsonValue.getFloat("restitution", 0f);
short group = jsonValue.getShort("group", (short) -1);
JsonValue maskList = jsonValue.get("mask");
short[] masks;
if (maskList != null) {
masks = maskList.asShortArray();
} else {
masks = new short[]{};
}
vehicleComponent.mass = mass;
vehicleComponent.friction = friction;
vehicleComponent.restitution = restitution;
vehicleComponent.collisionFiltering = true;
vehicleComponent.rigidBodyShape = shapeJson.get();
if (group != -1) {
vehicleComponent.group = (short) (1 << group);
} else {
vehicleComponent.collisionFiltering = false;
}
if (masks.length > 0) {
if (masks[0] != -1) {
vehicleComponent.mask = (short) (1 << masks[0]);
} else {
vehicleComponent.mask = 0;
}
for (int i = 1; i < masks.length; i++) {
vehicleComponent.mask |= (short) (1 << masks[i]);
}
} else {
vehicleComponent.collisionFiltering = false;
}
vehicleComponent.vehicleTuning = vehicleTuningJson.get();
output = vehicleComponent;
}