コード例 #1
0
  public void layout() {
    Table table = getTable();
    float width = table.getWidth();
    float height = table.getHeight();

    super.layout(0, 0, width, height);

    java.util.List<Cell> cells = getCells();
    if (round) {
      for (int i = 0, n = cells.size(); i < n; i++) {
        Cell c = cells.get(i);
        if (c.getIgnore()) continue;
        float widgetWidth = Math.round(c.getWidgetWidth());
        float widgetHeight = Math.round(c.getWidgetHeight());
        float widgetX = Math.round(c.getWidgetX());
        float widgetY = height - Math.round(c.getWidgetY()) - widgetHeight;
        c.setWidgetX(widgetX);
        c.setWidgetY(widgetY);
        c.setWidgetWidth(widgetWidth);
        c.setWidgetHeight(widgetHeight);
        Actor actor = (Actor) c.getWidget();
        if (actor != null) {
          actor.setX(widgetX);
          actor.setY(widgetY);
          if (actor.getWidth() != widgetWidth || actor.getHeight() != widgetHeight) {
            actor.setWidth(widgetWidth);
            actor.setHeight(widgetHeight);
            if (actor instanceof Layout) ((Layout) actor).invalidate();
          }
        }
      }
    } else {
      for (int i = 0, n = cells.size(); i < n; i++) {
        Cell c = cells.get(i);
        if (c.getIgnore()) continue;
        float widgetWidth = c.getWidgetWidth();
        float widgetHeight = c.getWidgetHeight();
        float widgetX = c.getWidgetX();
        float widgetY = height - c.getWidgetY() - widgetHeight;
        c.setWidgetX(widgetX);
        c.setWidgetY(widgetY);
        c.setWidgetWidth(widgetWidth);
        c.setWidgetHeight(widgetHeight);
        Actor actor = (Actor) c.getWidget();
        if (actor != null) {
          actor.setX(widgetX);
          actor.setY(widgetY);
          if (actor.getWidth() != widgetWidth || actor.getHeight() != widgetHeight) {
            actor.setWidth(widgetWidth);
            actor.setHeight(widgetHeight);
            if (actor instanceof Layout) ((Layout) actor).invalidate();
          }
        }
      }
    }
    // Validate children separately from sizing actors to ensure actors without a cell are
    // validated.
    Array<Actor> children = table.getChildren();
    for (int i = 0, n = children.size; i < n; i++) {
      Actor child = children.get(i);
      if (child instanceof Layout) ((Layout) child).validate();
    }
  }
コード例 #2
0
ファイル: Actor.java プロジェクト: newisso/libgdx
 /** Set bounds the x, y, width, and height. */
 public void setBounds(float x, float y, float width, float height) {
   setX(x);
   setY(y);
   setWidth(width);
   setHeight(height);
 }
コード例 #3
0
ファイル: Actor.java プロジェクト: newisso/libgdx
 /** Sets the x and y. */
 public void setPosition(float x, float y) {
   setX(x);
   setY(y);
 }
コード例 #4
0
ファイル: Actor.java プロジェクト: newisso/libgdx
 public void translate(float x, float y) {
   setX(this.x + x);
   setY(this.y + y);
 }
コード例 #5
0
 public static void moveActorCenterCenterX(Actor act, float x, float y) {
   act.setX(x - act.getWidth() / 2 + screenWidth / 2);
   act.setY(-y - act.getHeight() / 2 + screenHeight / 2);
 }