예제 #1
0
파일: Player.java 프로젝트: marshauf/uni
 @Override
 public void read(Json json, JsonValue jsonData) {
   Iterator<JsonValue> iter = jsonData.iterator();
   JsonValue value;
   while (iter.hasNext()) {
     value = iter.next();
     switch (value.name()) {
       case "name":
         name = value.asString();
         break;
       case "dir":
         dir.x = value.get("x").asFloat();
         dir.y = value.get("x").asFloat();
         break;
       case "speed":
         speed = value.asFloat();
         break;
       case "bounds":
         bounds.width = value.getFloat("width");
         bounds.height = value.getFloat("height");
         setPosition(
             new Vector2(
                 value.getFloat("x") + bounds.width / 2, value.getFloat("y") + bounds.height / 2));
         break;
       case "score":
         score.read(json, value);
         break;
     }
   }
 }
예제 #2
0
 void readCurve(CurveTimeline timeline, int frameIndex, JsonValue valueMap) {
   JsonValue curve = valueMap.get("curve");
   if (curve == null) return;
   if (curve.isString() && curve.asString().equals("stepped")) timeline.setStepped(frameIndex);
   else if (curve.isArray()) {
     timeline.setCurve(
         frameIndex, curve.getFloat(0), curve.getFloat(1), curve.getFloat(2), curve.getFloat(3));
   }
 }