Example usage for com.badlogic.gdx.utils Json writeObjectStart

List of usage examples for com.badlogic.gdx.utils Json writeObjectStart

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Json writeObjectStart.

Prototype

public void writeObjectStart(String name) 

Source Link

Usage

From source file:com.bladecoder.engine.model.Inventory.java

License:Apache License

@Override
public void write(Json json) {
    SceneActorRef actorRef;/*  w w  w .j a v a 2s . com*/

    json.writeValue("visible", visible);
    ;

    json.writeObjectStart("items");
    for (SpriteActor a : items) {
        actorRef = new SceneActorRef(a.getInitScene(), a.getId());
        json.writeValue(actorRef.toString(), a);
    }
    json.writeObjectEnd();
}

From source file:com.bladecoder.engine.model.Scene.java

License:Apache License

@Override
public void write(Json json) {
    if (SerializationHelper.getInstance().getMode() == Mode.MODEL) {

        json.writeValue("id", id);
        json.writeValue("layers", layers, layers.getClass(), SceneLayer.class);

        json.writeValue("actors", actors);

        if (backgroundAtlas != null) {
            json.writeValue("backgroundAtlas", backgroundAtlas);
            json.writeValue("backgroundRegionId", backgroundRegionId);
        }/*from  ww  w.j  ava  2s  . c o  m*/

        if (musicFilename != null) {
            json.writeValue("musicFilename", musicFilename);
            json.writeValue("loopMusic", loopMusic);
            json.writeValue("initialMusicDelay", initialMusicDelay);
            json.writeValue("repeatMusicDelay", repeatMusicDelay);
        }

        if (depthVector != null)
            json.writeValue("depthVector", depthVector);

        if (polygonalNavGraph != null)
            json.writeValue("polygonalNavGraph", polygonalNavGraph);

        if (sceneSize != null)
            json.writeValue("sceneSize", sceneSize);

    } else {
        SceneActorRef actorRef;

        json.writeObjectStart("actors");
        for (BaseActor a : actors.values()) {
            actorRef = new SceneActorRef(a.getInitScene(), a.getId());
            json.writeValue(actorRef.toString(), a);
        }
        json.writeObjectEnd();

        if (musicFilename != null) {
            json.writeValue("isPlaying", music != null && music.isPlaying());
            json.writeValue("musicPos", music != null && music.isPlaying() ? music.getPosition() : 0f);
        }

        json.writeValue("camera", camera);

        if (followActor != null)
            json.writeValue("followActor", followActor.getId());
    }

    verbs.write(json);

    if (state != null)
        json.writeValue("state", state);

    if (player != null)
        json.writeValue("player", player);
}

From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java

License:Apache License

void write1ResType(ObjectMap<String, ? extends Object> typeResources, Class<? extends Object> resType,
        Json json) {
    //  styleName ?.???
    Array<String> styleNames = typeResources.keys().toArray();
    // ??? resType ? ?
    for (String styleName : styleNames) {
        json.writeObjectStart(styleName);
        write1Style(json, resType, typeResources, styleName);
        json.writeObjectEnd();/*from   w  w w.  j ava 2 s  .  c  o  m*/
    }
}

From source file:com.strategames.engine.gameobject.GameObject.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeObjectStart(this.getClass().getSimpleName());
    //      json.writeObjectStart(this.getClass().getCanonicalName());
    Vector2 position = new Vector2();
    if (this.body != null) {
        position = this.body.getPosition();
    } else {//from  w  ww.  j ava 2 s . c om
        position.x = getX();
        position.y = getY();
    }

    json.writeValue("x", position.x);
    json.writeValue("y", position.y);

    json.writeValue("isNew", isNew);

    writeValues(json); //allow subclasses to add their own entries

    json.writeObjectEnd();
}

From source file:com.strategames.engine.math.Vector2.java

License:Open Source License

@Override
public void write(Json json) {
    json.writeObjectStart(this.getClass().getCanonicalName());
    json.writeValue("x", super.x);
    json.writeValue("y", super.y);
    json.writeObjectEnd();/*from   w w w .ja v a 2 s .c  o m*/
}

From source file:org.matheusdev.util.JsonDOM.java

License:Open Source License

public void writeJsonObject(JsonObject element, Json json) {
    for (Entry<String, String> entry : element.values.entries()) {
        json.writeValue(entry.key, entry.value);
    }//from  w  w  w  .j  a  v  a2s.  c  o  m
    for (Entry<String, JsonElement> entry : element.elements.entries()) {
        if (entry.value instanceof JsonObject) {
            json.writeObjectStart(entry.key);
            writeJsonObject((JsonObject) entry.value, json);
            json.writeObjectEnd();
        } else if (entry.value instanceof JsonArray) {
            json.writeArrayStart(entry.key);
            writeJsonArray((JsonArray) entry.value, json);
            json.writeArrayEnd();
        }
    }
}