本文整理汇总了Java中com.badlogic.gdx.utils.JsonValue.getShort方法的典型用法代码示例。如果您正苦于以下问题:Java JsonValue.getShort方法的具体用法?Java JsonValue.getShort怎么用?Java JsonValue.getShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.JsonValue
的用法示例。
在下文中一共展示了JsonValue.getShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.badlogic.gdx.utils.JsonValue; //导入方法依赖的package包/类
@Override
public void parse(JsonValue jsonValue) {
RigidBodyComponent rigidBodyComponent = nhg.entities.createComponent(entity, RigidBodyComponent.class);
ShapeJson shapeJson = new ShapeJson();
shapeJson.parse(jsonValue.get("shape"));
float mass = jsonValue.getFloat("mass", 1.0f);
float friction = jsonValue.getFloat("friction", 0.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[]{};
}
rigidBodyComponent.mass = mass;
rigidBodyComponent.friction = friction;
rigidBodyComponent.restitution = restitution;
rigidBodyComponent.collisionFiltering = true;
rigidBodyComponent.rigidBodyShape = shapeJson.get();
if (group != -1) {
rigidBodyComponent.group = (short) (1 << group);
} else {
rigidBodyComponent.collisionFiltering = false;
}
if (masks.length > 0) {
if (masks[0] != -1) {
rigidBodyComponent.mask = (short) (1 << masks[0]);
} else {
rigidBodyComponent.mask = 0;
}
for (int i = 1; i < masks.length; i++) {
rigidBodyComponent.mask |= (short) (1 << masks[i]);
}
} else {
rigidBodyComponent.collisionFiltering = false;
}
output = rigidBodyComponent;
}
示例2: 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;
}