本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.getParent()
方法的一些代码示例,展示了Actor.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.getParent()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:getParent
[英]Returns the parent actor, or null if not in a group.
[中]返回父参与者,如果不在组中,则返回null。
代码示例来源:origin: libgdx/libgdx
/** Returns the tree this node is currently in, or null. */
public Tree getTree () {
Group parent = actor.getParent();
if (!(parent instanceof Tree)) return null;
return (Tree)parent;
}
代码示例来源:origin: libgdx/libgdx
/** Returns the tree this node is currently in, or null. */
public Tree getTree () {
Group parent = actor.getParent();
if (!(parent instanceof Tree)) return null;
return (Tree)parent;
}
代码示例来源:origin: libgdx/libgdx
/** Sets the actor in this cell and adds the actor to the cell's table. If null, removes any current actor. */
public <A extends Actor> Cell<A> setActor (A newActor) {
if (actor != newActor) {
if (actor != null && actor.getParent() == table) actor.remove();
actor = newActor;
if (newActor != null) table.addActor(newActor);
}
return (Cell<A>)this;
}
代码示例来源:origin: libgdx/libgdx
public void changed (ChangeEvent event, Actor actor) {
if (!values.containsKey(actor)) return;
while (actor.getParent() != buttonTable)
actor = actor.getParent();
result(values.get(actor));
if (!cancelHide) hide();
cancelHide = false;
}
});
代码示例来源:origin: libgdx/libgdx
public void changed (ChangeEvent event, Actor actor) {
if (!values.containsKey(actor)) return;
while (actor.getParent() != buttonTable)
actor = actor.getParent();
result(values.get(actor));
if (!cancelHide) hide();
cancelHide = false;
}
});
代码示例来源:origin: libgdx/libgdx
/** Sets the actor in this cell and adds the actor to the cell's table. If null, removes any current actor. */
public <A extends Actor> Cell<A> setActor (A newActor) {
if (actor != newActor) {
if (actor != null && actor.getParent() == table) actor.remove();
actor = newActor;
if (newActor != null) table.addActor(newActor);
}
return (Cell<A>)this;
}
代码示例来源:origin: libgdx/libgdx
public Actor hit (float x, float y, boolean touchable) {
if (!isVisible()) return null;
Actor hit = super.hit(x, y, touchable);
if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this;
float height = getHeight();
if (hit == null || hit == this) return hit;
if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) {
// Hit the title bar, don't use the hit child if it is in the Window's table.
Actor current = hit;
while (current.getParent() != this)
current = current.getParent();
if (getCell(current) != null) return this;
}
return hit;
}
代码示例来源:origin: libgdx/libgdx
public Actor hit (float x, float y, boolean touchable) {
if (!isVisible()) return null;
Actor hit = super.hit(x, y, touchable);
if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this;
float height = getHeight();
if (hit == null || hit == this) return hit;
if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) {
// Hit the title bar, don't use the hit child if it is in the Window's table.
Actor current = hit;
while (current.getParent() != this)
current = current.getParent();
if (getCell(current) != null) return this;
}
return hit;
}
代码示例来源:origin: libgdx/libgdx
/** @return May be null. */
private TextField findNextTextField (Array<Actor> actors, TextField best, Vector2 bestCoords, Vector2 currentCoords,
boolean up) {
for (int i = 0, n = actors.size; i < n; i++) {
Actor actor = actors.get(i);
if (actor instanceof TextField) {
if (actor == this) continue;
TextField textField = (TextField)actor;
if (textField.isDisabled() || !textField.focusTraversal || !textField.ancestorsVisible()) continue;
Vector2 actorCoords = actor.getParent().localToStageCoordinates(tmp3.set(actor.getX(), actor.getY()));
boolean below = actorCoords.y != currentCoords.y && (actorCoords.y < currentCoords.y ^ up);
boolean right = actorCoords.y == currentCoords.y && (actorCoords.x > currentCoords.x ^ up);
if (!below && !right) continue;
boolean better = best == null || (actorCoords.y != bestCoords.y && (actorCoords.y > bestCoords.y ^ up));
if (!better) better = actorCoords.y == bestCoords.y && (actorCoords.x < bestCoords.x ^ up);
if (better) {
best = (TextField)actor;
bestCoords.set(actorCoords);
}
} else if (actor instanceof Group)
best = findNextTextField(((Group)actor).getChildren(), best, bestCoords, currentCoords, up);
}
return best;
}
代码示例来源:origin: libgdx/libgdx
/** @return May be null. */
private TextField findNextTextField (Array<Actor> actors, TextField best, Vector2 bestCoords, Vector2 currentCoords,
boolean up) {
for (int i = 0, n = actors.size; i < n; i++) {
Actor actor = actors.get(i);
if (actor instanceof TextField) {
if (actor == this) continue;
TextField textField = (TextField)actor;
if (textField.isDisabled() || !textField.focusTraversal || !textField.ancestorsVisible()) continue;
Vector2 actorCoords = actor.getParent().localToStageCoordinates(tmp3.set(actor.getX(), actor.getY()));
boolean below = actorCoords.y != currentCoords.y && (actorCoords.y < currentCoords.y ^ up);
boolean right = actorCoords.y == currentCoords.y && (actorCoords.x > currentCoords.x ^ up);
if (!below && !right) continue;
boolean better = best == null || (actorCoords.y != bestCoords.y && (actorCoords.y > bestCoords.y ^ up));
if (!better) better = actorCoords.y == bestCoords.y && (actorCoords.x < bestCoords.x ^ up);
if (better) {
best = (TextField)actor;
bestCoords.set(actorCoords);
}
} else if (actor instanceof Group)
best = findNextTextField(((Group)actor).getChildren(), best, bestCoords, currentCoords, up);
}
return best;
}
代码示例来源:origin: libgdx/libgdx
private boolean isCulled () {
// we start by setting the stage coordinates to this
// actors coordinates which are relative to its parent
// Group.
float stageX = getX();
float stageY = getY();
// now we go up the hierarchy and add all the parents'
// coordinates to this actors coordinates. Note that
// this assumes that neither this actor nor any of its
// parents are rotated or scaled!
Actor parent = this.getParent();
while (parent != null) {
stageX += parent.getX();
stageY += parent.getY();
parent = parent.getParent();
}
// now we check if the rectangle of this actor in screen
// coordinates is in the rectangle spanned by the camera's
// view. This assumes that the camera has no zoom and is
// not rotated!
actorRect.set(stageX, stageY, getWidth(), getHeight());
camRect.set(camera.position.x - camera.viewportWidth / 2.0f, camera.position.y - camera.viewportHeight / 2.0f,
camera.viewportWidth, camera.viewportHeight);
visible = camRect.overlaps(actorRect);
return !visible;
}
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Returns the tree this node is currently in, or null. */
public Tree getTree () {
Group parent = actor.getParent();
if (!(parent instanceof Tree)) return null;
return (Tree)parent;
}
代码示例来源:origin: kotcrab/vis-ui
/**
* @param actor might be in the drag pane.
* @return true if actor is added to the pane's internal group.
*/
public boolean contains (final Actor actor) {
return actor.getParent() == getActor();
}
代码示例来源:origin: kotcrab/vis-ui
/**
* Checks if actor is visible in stage acknowledging parent visibility.
* If any parent returns false from isVisible then this method return false.
* True is returned when this actor and all its parent are visible.
*/
private boolean isActorVisibleInStage (Actor actor) {
if (actor == null) return true;
if (actor.isVisible() == false) return false;
return isActorVisibleInStage(actor.getParent());
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public void changed (ChangeEvent event, Actor actor) {
if (!values.containsKey(actor)) return;
while (actor.getParent() != buttonTable)
actor = actor.getParent();
result(values.get(actor));
if (!cancelHide) hide();
cancelHide = false;
}
});
代码示例来源:origin: kotcrab/vis-ui
@Override
public void changed (ChangeEvent event, Actor actor) {
if (!values.containsKey(actor)) return;
while (actor.getParent() != buttonTable)
actor = actor.getParent();
result(values.get(actor));
if (!cancelHide) hide();
cancelHide = false;
}
});
代码示例来源:origin: kotcrab/vis-ui
private Window findModalWindow (Actor actor) {
if (actor == null) return null;
if (actor instanceof Window && ((Window) actor).isModal()) return (Window) actor;
return findModalWindow(actor.getParent());
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Sets the actor in this cell and adds the actor to the cell's table. If null, removes any current actor. */
public <A extends Actor> Cell<A> setActor (A newActor) {
if (actor != newActor) {
if (actor != null && actor.getParent() == table) actor.remove();
actor = newActor;
if (newActor != null) table.addActor(newActor);
}
return (Cell<A>)this;
}
代码示例来源:origin: dingjibang/GDX-RPG
public static float absoluteY(Actor actor){
float val = 0;
val += actor.getY();
Actor parent = actor;
while(true){
Actor _p = parent.getParent();
if(_p == null) break;
val += parent.localToParentCoordinates(new Vector2(parent.getX(),parent.getY())).y;
parent = parent.getParent();
}
return val;
}
代码示例来源:origin: dingjibang/GDX-RPG
public static float absoluteX(Actor actor){
float val = 0;
val += actor.getX();
Actor parent = actor;
while(true){
Actor _p = parent.getParent();
if(_p == null) break;
val += parent.localToParentCoordinates(new Vector2(0,0)).x;
parent = _p;
}
return val;
}
内容来源于网络,如有侵权,请联系作者删除!