void toast(String text) {
   Table table = new Table();
   table.add(new Label(text, skin));
   table.getColor().a = 0;
   table.pack();
   table.setPosition(-table.getWidth(), -3 - table.getHeight());
   table.addAction(
       sequence( //
           parallel(moveBy(0, table.getHeight(), 0.3f), fadeIn(0.3f)), //
           delay(5f), //
           parallel(moveBy(0, table.getHeight(), 0.3f), fadeOut(0.3f)), //
           removeActor() //
           ));
   for (Actor actor : toasts.getChildren()) actor.addAction(moveBy(0, table.getHeight(), 0.3f));
   toasts.addActor(table);
   toasts.getParent().toFront();
 }
Ejemplo n.º 2
0
  private void invalidateChildren(WidgetGroup group) {
    SnapshotArray<Actor> children = group.getChildren();

    Actor actor;
    for (int i = 0; i < children.size; i++) {
      actor = children.get(i);
      if (actor instanceof Layout) {
        // UIWidgets are the best! :D
        ((Layout) actor).invalidate();
      }

      if (actor instanceof WidgetGroup) {
        // If it's a group, recurse
        invalidateChildren((WidgetGroup) actor);
      }
    }

    group.invalidate();
  }
Ejemplo n.º 3
0
  /**
   * Recursively refresh the skin for each Widget
   *
   * @param group
   */
  public void reskin(WidgetGroup group) {
    Skin skin = game.getSkin();
    SnapshotArray<Actor> children = group.getChildren();

    /**
     * This code is horrendously ugly. I'm so sorry. :( However, I can't think of a better way to do
     * it.
     */
    Actor actor;
    for (int i = 0; i < children.size; i++) {
      actor = children.get(i);
      if (actor instanceof UIWidget) {
        // UIWidgets are the best! :D
        ((UIWidget) actor).reskin(skin);
      }

      if (actor instanceof WidgetGroup) {
        // If it's a group, recurse
        reskin((WidgetGroup) actor);
      }
    }

    group.validate();
  }