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


Java JsonValue.getShort方法代码示例

本文整理汇总了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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:51,代码来源:RigidBodyComponentJson.java

示例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;
}
 
开发者ID:MovementSpeed,项目名称:nhglib,代码行数:64,代码来源:VehicleComponentJson.java


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