當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。