本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.getStage()
方法的一些代码示例,展示了Actor.getStage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.getStage()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:getStage
[英]Returns the stage that this actor is currently in, or null if not in a stage.
[中]返回此参与者当前所在的阶段,如果不在阶段中,则返回null。
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is a listener actor for touch focus.
* @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */
public boolean isTouchFocusListener () {
Stage stage = getStage();
if (stage == null) return false;
for (int i = 0, n = stage.touchFocuses.size; i < n; i++)
if (stage.touchFocuses.get(i).listenerActor == this) return true;
return false;
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is the {@link Stage#getKeyboardFocus() keyboard focus} actor. */
public boolean hasKeyboardFocus () {
Stage stage = getStage();
return stage != null && stage.getKeyboardFocus() == this;
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is the {@link Stage#getScrollFocus() scroll focus} actor. */
public boolean hasScrollFocus () {
Stage stage = getStage();
return stage != null && stage.getScrollFocus() == this;
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is the {@link Stage#getKeyboardFocus() keyboard focus} actor. */
public boolean hasKeyboardFocus () {
Stage stage = getStage();
return stage != null && stage.getKeyboardFocus() == this;
}
代码示例来源:origin: libgdx/libgdx
public Target (Actor actor) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
this.actor = actor;
Stage stage = actor.getStage();
if (stage != null && actor == stage.getRoot())
throw new IllegalArgumentException("The stage root cannot be a drag and drop target.");
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is the {@link Stage#getScrollFocus() scroll focus} actor. */
public boolean hasScrollFocus () {
Stage stage = getStage();
return stage != null && stage.getScrollFocus() == this;
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is a listener actor for touch focus.
* @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */
public boolean isTouchFocusListener () {
Stage stage = getStage();
if (stage == null) return false;
for (int i = 0, n = stage.touchFocuses.size; i < n; i++)
if (stage.touchFocuses.get(i).listenerActor == this) return true;
return false;
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is a target actor for touch focus.
* @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */
public boolean isTouchFocusTarget () {
Stage stage = getStage();
if (stage == null) return false;
for (int i = 0, n = stage.touchFocuses.size; i < n; i++)
if (stage.touchFocuses.get(i).target == this) return true;
return false;
}
代码示例来源:origin: libgdx/libgdx
public Target (Actor actor) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
this.actor = actor;
Stage stage = actor.getStage();
if (stage != null && actor == stage.getRoot())
throw new IllegalArgumentException("The stage root cannot be a drag and drop target.");
}
代码示例来源:origin: libgdx/libgdx
/** Returns true if this actor is a target actor for touch focus.
* @see Stage#addTouchFocus(EventListener, Actor, Actor, int, int) */
public boolean isTouchFocusTarget () {
Stage stage = getStage();
if (stage == null) return false;
for (int i = 0, n = stage.touchFocuses.size; i < n; i++)
if (stage.touchFocuses.get(i).target == this) return true;
return false;
}
代码示例来源:origin: libgdx/libgdx
public void act (float delta) {
super.act(delta);
if (targetActor != null && targetActor.getStage() == null) remove();
}
};
代码示例来源:origin: libgdx/libgdx
public void act (float delta) {
super.act(delta);
if (targetActor != null && targetActor.getStage() == null) remove();
}
};
代码示例来源:origin: libgdx/libgdx
/** Cancels the touch focus for everything except the specified source. */
public void cancelTouchFocusExcept (Source except) {
DragListener listener = sourceListeners.get(except);
if (listener == null) return;
except.getActor().getStage().cancelTouchFocusExcept(listener, except.getActor());
}
代码示例来源:origin: libgdx/libgdx
/** Cancels the touch focus for everything except the specified source. */
public void cancelTouchFocusExcept (Source except) {
DragListener listener = sourceListeners.get(except);
if (listener == null) return;
except.getActor().getStage().cancelTouchFocusExcept(listener, except.getActor());
}
代码示例来源:origin: libgdx/libgdx
public void dragStart (InputEvent event, float x, float y, int pointer) {
if (activePointer != -1) {
event.stop();
return;
}
activePointer = pointer;
dragStartTime = System.currentTimeMillis();
dragSource = source;
payload = source.dragStart(event, getTouchDownX(), getTouchDownY(), pointer);
event.stop();
if (cancelTouchFocus && payload != null) source.getActor().getStage().cancelTouchFocusExcept(this, source.getActor());
}
代码示例来源:origin: libgdx/libgdx
public void dragStart (InputEvent event, float x, float y, int pointer) {
if (activePointer != -1) {
event.stop();
return;
}
activePointer = pointer;
dragStartTime = System.currentTimeMillis();
dragSource = source;
payload = source.dragStart(event, getTouchDownX(), getTouchDownY(), pointer);
event.stop();
if (cancelTouchFocus && payload != null) source.getActor().getStage().cancelTouchFocusExcept(this, source.getActor());
}
代码示例来源:origin: libgdx/libgdx
public void run () {
if (showTooltip == null || showTooltip.targetActor == null) return;
Stage stage = showTooltip.targetActor.getStage();
if (stage == null) return;
stage.addActor(showTooltip.container);
showTooltip.container.toFront();
shown.add(showTooltip);
showTooltip.container.clearActions();
showAction(showTooltip);
if (!showTooltip.instant) {
time = subsequentTime;
resetTask.cancel();
}
}
};
代码示例来源:origin: libgdx/libgdx
public void hide () {
if (!list.isTouchable() || !hasParent()) return;
list.setTouchable(Touchable.disabled);
Stage stage = getStage();
if (stage != null) {
stage.removeCaptureListener(hideListener);
stage.removeListener(list.getKeyListener());
if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
Actor actor = stage.getScrollFocus();
if (actor == null || isAscendantOf(actor)) stage.setScrollFocus(previousScrollFocus);
}
clearActions();
selectBox.onHide(this);
}
代码示例来源:origin: libgdx/libgdx
public void hide () {
if (!list.isTouchable() || !hasParent()) return;
list.setTouchable(Touchable.disabled);
Stage stage = getStage();
if (stage != null) {
stage.removeCaptureListener(hideListener);
stage.removeListener(list.getKeyListener());
if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
Actor actor = stage.getScrollFocus();
if (actor == null || isAscendantOf(actor)) stage.setScrollFocus(previousScrollFocus);
}
clearActions();
selectBox.onHide(this);
}
代码示例来源:origin: libgdx/libgdx
private void setContainerPosition (Actor actor, float x, float y) {
this.targetActor = actor;
Stage stage = actor.getStage();
if (stage == null) return;
container.pack();
float offsetX = manager.offsetX, offsetY = manager.offsetY, dist = manager.edgeDistance;
Vector2 point = actor.localToStageCoordinates(tmp.set(x + offsetX, y - offsetY - container.getHeight()));
if (point.y < dist) point = actor.localToStageCoordinates(tmp.set(x + offsetX, y + offsetY));
if (point.x < dist) point.x = dist;
if (point.x + container.getWidth() > stage.getWidth() - dist) point.x = stage.getWidth() - dist - container.getWidth();
if (point.y + container.getHeight() > stage.getHeight() - dist) point.y = stage.getHeight() - dist - container.getHeight();
container.setPosition(point.x, point.y);
point = actor.localToStageCoordinates(tmp.set(actor.getWidth() / 2, actor.getHeight() / 2));
point.sub(container.getX(), container.getY());
container.setOrigin(point.x, point.y);
}
内容来源于网络,如有侵权,请联系作者删除!