예제 #1
0
 /**
  * 删除指定集合中的所有角色
  *
  * @param objects
  */
 public void removeObjects(TArray<Actor> objects) {
   if (isClose) {
     return;
   }
   synchronized (objects) {
     Iterator<Actor> iter = objects.iterator();
     while (iter.hasNext()) {
       Actor actor = iter.next();
       this.removeObject(actor);
     }
   }
 }
예제 #2
0
파일: BMFont.java 프로젝트: lwxcool/LGame
  private void parse(String text) throws Exception {
    if (displays == null) {
      displays = new ObjectMap<String, Display>(DEFAULT_MAX_CHAR);
    } else {
      displays.clear();
    }
    StringTokenizer br = new StringTokenizer(text, LSystem.LS);
    info = br.nextToken();
    common = br.nextToken();
    page = br.nextToken();

    ObjectMap<Short, TArray<Short>> kerning = new ObjectMap<Short, TArray<Short>>(64);
    TArray<CharDef> charDefs = new TArray<CharDef>(DEFAULT_MAX_CHAR);

    int maxChar = 0;
    boolean done = false;
    for (; !done; ) {
      String line = br.nextToken();
      if (line == null) {
        done = true;
      } else {
        if (line.startsWith("chars c")) {
        } else if (line.startsWith("char")) {
          CharDef def = parseChar(line);
          if (def != null) {
            maxChar = MathUtils.max(maxChar, def.id);
            charDefs.add(def);
          }
        }
        if (line.startsWith("kernings c")) {
        } else if (line.startsWith("kerning")) {
          StringTokenizer tokens = new StringTokenizer(line, " =");
          tokens.nextToken();
          tokens.nextToken();
          short first = Short.parseShort(tokens.nextToken());
          tokens.nextToken();
          int second = Integer.parseInt(tokens.nextToken());
          tokens.nextToken();
          int offset = Integer.parseInt(tokens.nextToken());
          TArray<Short> values = kerning.get(new Short(first));
          if (values == null) {
            values = new TArray<Short>();
            kerning.put(new Short(first), values);
          }
          values.add(new Short((short) ((offset << 8) | second)));
        }
      }
    }

    this.chars = new CharDef[maxChar + 1];

    for (Iterator<CharDef> iter = charDefs.iterator(); iter.hasNext(); ) {
      CharDef def = iter.next();
      chars[def.id] = def;
    }

    for (Entries<Short, TArray<Short>> iter = kerning.entries(); iter.hasNext(); ) {
      Entry<Short, TArray<Short>> entry = iter.next();
      short first = entry.key;
      TArray<Short> valueList = entry.value;
      short[] valueArray = new short[valueList.size];
      int i = 0;
      for (Iterator<Short> valueIter = valueList.iterator(); valueIter.hasNext(); i++) {
        valueArray[i] = (valueIter.next()).shortValue();
      }
      chars[first].kerning = valueArray;
    }
  }