本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.getY()
方法的一些代码示例,展示了Actor.getY()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.getY()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:getY
[英]Returns the Y position of the actor's bottom edge.
[中]返回演员底边的Y位置。
代码示例来源:origin: libgdx/libgdx
protected void begin () {
startX = target.getX(alignment);
startY = target.getY(alignment);
}
代码示例来源:origin: libgdx/libgdx
protected void begin () {
startX = target.getX(alignment);
startY = target.getY(alignment);
}
代码示例来源:origin: libgdx/libgdx
void selectNodes (Array<Node> nodes, float low, float high) {
for (int i = 0, n = nodes.size; i < n; i++) {
Node node = nodes.get(i);
if (node.actor.getY() < low) break;
if (!node.isSelectable()) continue;
if (node.actor.getY() <= high) selection.add(node);
if (node.expanded) selectNodes(node.children, low, high);
}
}
代码示例来源:origin: libgdx/libgdx
void selectNodes (Array<Node> nodes, float low, float high) {
for (int i = 0, n = nodes.size; i < n; i++) {
Node node = nodes.get(i);
if (node.actor.getY() < low) break;
if (!node.isSelectable()) continue;
if (node.actor.getY() <= high) selection.add(node);
if (node.expanded) selectNodes(node.children, low, high);
}
}
代码示例来源:origin: libgdx/libgdx
/** Draws selection, icons, and expand icons. */
private void draw (Batch batch, Array<Node> nodes, float indent, float plusMinusWidth) {
Drawable plus = style.plus, minus = style.minus;
float x = getX(), y = getY(), expandX = x + indent, iconX = expandX + plusMinusWidth + iconSpacingLeft;
for (int i = 0, n = nodes.size; i < n; i++) {
Node node = nodes.get(i);
float height = node.height;
Actor actor = node.actor;
if (selection.contains(node) && style.selection != null) {
style.selection.draw(batch, x, y + actor.getY() - ySpacing / 2, getWidth(), height + ySpacing);
} else if (node == overNode && style.over != null) {
style.over.draw(batch, x, y + actor.getY() - ySpacing / 2, getWidth(), height + ySpacing);
}
if (node.icon != null) {
float iconY = y + actor.getY() + Math.round((height - node.icon.getMinHeight()) / 2);
batch.setColor(actor.getColor());
node.icon.draw(batch, iconX, iconY, node.icon.getMinWidth(), node.icon.getMinHeight());
batch.setColor(Color.WHITE);
}
if (node.children.size == 0) continue;
Drawable expandIcon = node.expanded ? minus : plus;
float iconY = y + actor.getY() + Math.round((height - expandIcon.getMinHeight()) / 2);
expandIcon.draw(batch, expandX, iconY, expandIcon.getMinWidth(), expandIcon.getMinHeight());
if (node.expanded) draw(batch, node.children, indent + indentSpacing, plusMinusWidth);
}
}
代码示例来源:origin: libgdx/libgdx
/** Draws selection, icons, and expand icons. */
private void draw (Batch batch, Array<Node> nodes, float indent, float plusMinusWidth) {
Drawable plus = style.plus, minus = style.minus;
float x = getX(), y = getY(), expandX = x + indent, iconX = expandX + plusMinusWidth + iconSpacingLeft;
for (int i = 0, n = nodes.size; i < n; i++) {
Node node = nodes.get(i);
float height = node.height;
Actor actor = node.actor;
if (selection.contains(node) && style.selection != null) {
style.selection.draw(batch, x, y + actor.getY() - ySpacing / 2, getWidth(), height + ySpacing);
} else if (node == overNode && style.over != null) {
style.over.draw(batch, x, y + actor.getY() - ySpacing / 2, getWidth(), height + ySpacing);
}
if (node.icon != null) {
float iconY = y + actor.getY() + Math.round((height - node.icon.getMinHeight()) / 2);
batch.setColor(actor.getColor());
node.icon.draw(batch, iconX, iconY, node.icon.getMinWidth(), node.icon.getMinHeight());
batch.setColor(Color.WHITE);
}
if (node.children.size == 0) continue;
Drawable expandIcon = node.expanded ? minus : plus;
float iconY = y + actor.getY() + Math.round((height - expandIcon.getMinHeight()) / 2);
expandIcon.draw(batch, expandX, iconY, expandIcon.getMinWidth(), expandIcon.getMinHeight());
if (node.expanded) draw(batch, node.children, indent + indentSpacing, plusMinusWidth);
}
}
代码示例来源: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: libgdx/libgdx
Node rangeStart = Tree.this.rangeStart;
if (!UIUtils.ctrl()) selection.clear();
float start = rangeStart.actor.getY(), end = node.actor.getY();
if (start > end)
selectNodes(rootNodes, end, start);
代码示例来源:origin: libgdx/libgdx
Node rangeStart = Tree.this.rangeStart;
if (!UIUtils.ctrl()) selection.clear();
float start = rangeStart.actor.getY(), end = node.actor.getY();
if (start > end)
selectNodes(rootNodes, end, start);
代码示例来源:origin: stackoverflow.com
for(Actor actor : stage.getActors())
{
Vector3 windowCoordinates = new Vector3(actor.getX(), actor.getY(), 0);
camera.project(windowCoordinates);
if(windowCoordinates.x + actor.getWidth() < 0)
actor.remove();
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
void selectNodes (Array<Node> nodes, float low, float high) {
for (int i = 0, n = nodes.size; i < n; i++) {
Node node = nodes.get(i);
if (node.actor.getY() < low) break;
if (!node.isSelectable()) continue;
if (node.actor.getY() <= high) selection.add(node);
if (node.expanded) selectNodes(node.children, low, high);
}
}
代码示例来源: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: moribitotech/MTX
/**
* Get the rectangle of an actor from its current position and size
* */
public static Rectangle getRectangleOfActor(Actor actor) {
return new Rectangle(actor.getX(), actor.getY(), actor.getWidth(),
actor.getHeight());
}
代码示例来源:origin: Var3D/var3dframe
/**
* r1是否和r2相交
*/
public boolean isContains(Actor r1, Actor r2) {
rect1.set(r1.getX(), r1.getY(), r1.getWidth(), r1.getHeight());
rect2.set(r2.getX(), r2.getY(), r2.getWidth(), r2.getHeight());
return rect2.contains(rect1);
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
/**
* @param listView should has {@link ItemAdapter}
* @param item to scroll to
*/
public static void scrollDownToSelectedListItem(ListView listView, Object item) {
ItemAdapter adapter = (ItemAdapter) listView.getAdapter();
Actor itemView = adapter.getView(item);
listView.getScrollPane().scrollTo(0, itemView.getY(), 0, itemView.getHeight());
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
public void draw(Batch batch, float parentAlpha) {
Color col = getColor();
batch.setColor(col.r, col.g, col.b, col.a * parentAlpha);
drawable.draw(batch, getX(), getY(), getWidth(), actor.getY());
drawable.draw(batch, getX(), getY() + actor.getY() + actor.getHeight(), getWidth(), getHeight() - (actor.getY() + actor.getHeight()));
drawable.draw(batch, getX(), getY() + actor.getY(), actor.getX(), actor.getHeight());
drawable.draw(batch, getX() + (actor.getX() + actor.getWidth()), getY() + actor.getY(), getWidth() - (actor.getX() + actor.getWidth()), actor.getHeight());
}
}
代码示例来源:origin: kotcrab/vis-ui
@Override
public void draw (final Batch batch, final float parentAlpha) {
if (actor != null) {
LAST_POSITION.set(actor.getX(), actor.getY());
actor.setPosition(getX(), getY());
actor.draw(batch, getColor().a * parentAlpha);
actor.setPosition(LAST_POSITION.x, LAST_POSITION.y);
}
}
}
代码示例来源:origin: dingjibang/GDX-RPG
public TypedGdxQuery<T> center(boolean setPosition) {
t.setOrigin(Align.center);
if(t instanceof Image)
((Image)t).setAlign(Align.center);
if(t instanceof Label)
((Label) t).setAlignment(Align.center);
if(setPosition) {
t.setX(t.getX() - t.getWidth() / 2);
t.setY(t.getY() - t.getHeight() / 2);
}
return this;
}
内容来源于网络,如有侵权,请联系作者删除!