com.badlogic.gdx.scenes.scene2d.Stage.unfocus()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.6k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.unfocus()方法的一些代码示例,展示了Stage.unfocus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.unfocus()方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:unfocus

Stage.unfocus介绍

[英]Removes the touch, keyboard, and scroll focus for the specified actor and any descendants.
[中]移除指定演员及其后代的触摸、键盘和滚动焦点。

代码示例

代码示例来源:origin: libgdx/libgdx

/** Removes an actor from this group. If the actor will not be used again and has actions, they should be
 * {@link Actor#clearActions() cleared} so the actions will be returned to their
 * {@link Action#setPool(com.badlogic.gdx.utils.Pool) pool}, if any. This is not done automatically.
 * @param unfocus If true, {@link Stage#unfocus(Actor)} is called.
 * @return true if the actor was removed from this group. */
public boolean removeActor (Actor actor, boolean unfocus) {
  if (!children.removeValue(actor, true)) return false;
  if (unfocus) {
    Stage stage = getStage();
    if (stage != null) stage.unfocus(actor);
  }
  actor.setParent(null);
  actor.setStage(null);
  childrenChanged();
  return true;
}

代码示例来源:origin: libgdx/libgdx

/** Removes an actor from this group. If the actor will not be used again and has actions, they should be
 * {@link Actor#clearActions() cleared} so the actions will be returned to their
 * {@link Action#setPool(com.badlogic.gdx.utils.Pool) pool}, if any. This is not done automatically.
 * @param unfocus If true, {@link Stage#unfocus(Actor)} is called.
 * @return true if the actor was removed from this group. */
public boolean removeActor (Actor actor, boolean unfocus) {
  if (!children.removeValue(actor, true)) return false;
  if (unfocus) {
    Stage stage = getStage();
    if (stage != null) stage.unfocus(actor);
  }
  actor.setParent(null);
  actor.setStage(null);
  childrenChanged();
  return true;
}

代码示例来源:origin: crashinvaders/gdx-texture-packer-gui

@Override
  public boolean act(float delta) {
    if (done) return true;

    Actor target = getTarget();
    Stage stage = target.getStage();
    if (stage != null) {
      stage.unfocus(target);
    }
    done = true;
    return true;
  }
}

代码示例来源:origin: com.badlogicgames.gdx/gdx

/** Removes an actor from this group. If the actor will not be used again and has actions, they should be
 * {@link Actor#clearActions() cleared} so the actions will be returned to their
 * {@link Action#setPool(com.badlogic.gdx.utils.Pool) pool}, if any. This is not done automatically.
 * @param unfocus If true, {@link Stage#unfocus(Actor)} is called.
 * @return true if the actor was removed from this group. */
public boolean removeActor (Actor actor, boolean unfocus) {
  if (!children.removeValue(actor, true)) return false;
  if (unfocus) {
    Stage stage = getStage();
    if (stage != null) stage.unfocus(actor);
  }
  actor.setParent(null);
  actor.setStage(null);
  childrenChanged();
  return true;
}

代码示例来源:origin: kotcrab/vis-ui

/**
 * Removes an actor from this group. If the actor will not be used again and has actions, they should be
 * {@link Actor#clearActions() cleared} so the actions will be returned to their
 * {@link Action#setPool(com.badlogic.gdx.utils.Pool) pool}, if any. This is not done automatically.
 * <p>
 * Note that the direct parent of {@link DragPane}'s children is the internal pane's group accessible through
 * {@link #getGroup()} - and since this removal method is overridden and extended, pane's children should be deleted with
 * {@code dragPane.removeActor(child, true)} rather than {@link Actor#remove()} method.
 * @param unfocus if true, {@link Stage#unfocus(Actor)} is called.
 * @param actor will be removed, if present in the internal {@link WidgetGroup}.
 * @return true if the actor was removed from this group.
 */
@Override
public boolean removeActor (final Actor actor, final boolean unfocus) {
  if (getActor().getChildren().contains(actor, true)) {
    // Stage input focus causes problems, as touchUp is called in Draggable. Reproducing input unfocus after stage removed.
    Stage stage = actor.getStage();
    getActor().removeActor(actor, false); // Stage is cleared.
    if (unfocus && stage != null) {
      stage.unfocus(actor);
    }
    return true;
  }
  return false;
}

相关文章