本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.getX()
方法的一些代码示例,展示了Actor.getX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.getX()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:getX
[英]Returns the X position of the actor's left edge.
[中]返回演员左边缘的X位置。
代码示例来源: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
/** @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
float rowX = node.actor.getX();
if (node.icon != null) rowX -= iconSpacingRight + node.icon.getMinWidth();
if (x < rowX) {
代码示例来源:origin: libgdx/libgdx
float rowX = node.actor.getX();
if (node.icon != null) rowX -= iconSpacingRight + node.icon.getMinWidth();
if (x < rowX) {
代码示例来源: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: stackoverflow.com
tileActor.addListener(new DragListener() {
private float offsetX, offsetY;
@Override
public void dragStart(InputEvent event, float x, float y, int pointer) {
Actor target = event.getTarget();
this.offsetX = event.getStageX() - target.getX();
this.offsetY = event.getStageY() - target.getY();
}
@Override
public void drag(InputEvent event, float x, float y, int pointer) {
event.getTarget().setPosition(event.getStageX() - offsetX, event.getStageY() - offsetY);
}
});
代码示例来源:origin: Var3D/var3dframe
public void touchUp(InputEvent event, float px, float py,
int pointer, int but) {
Clipboard clip = Gdx.app.getClipboard();
clip.setContents(".setPosition(" + (int) actor.getX() + "," + (int) actor.getY() + ")");
}
});
代码示例来源: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;
}
代码示例来源:origin: Var3D/var3dframe
@Override
protected void update(float percent) {
if (temp == null) {
temp = new Vector2(actor.getX(), actor.getY());
}
// TODO Auto-generated method stub
valueAt(temp, percent);
actor.setPosition(temp.x, temp.y);
}
代码示例来源:origin: SquidPony/SquidLib
/**
* Draws one AnimatedEntity, specifically the Actor it contains. Batch must be between start() and end()
* @param batch Must have start() called already but not stop() yet during this frame.
* @param parentAlpha This can be assumed to be 1.0f if you don't know it
* @param ac The Actor to draw; the position to draw ac is modified and reset based on some fields of this object
*/
public void drawActor(Batch batch, float parentAlpha, Actor ac)
{
float prevX = ac.getX(), prevY = ac.getY();
ac.setPosition(prevX - gridOffsetX * cellWidth, prevY + gridOffsetY * cellHeight);
ac.draw(batch, parentAlpha);
ac.setPosition(prevX, prevY);
}
代码示例来源: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: 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: 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;
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
public boolean replaceChildWith(Actor actorToRemove, Actor actorToInsert) {
int index = getChildren().indexOf(actorToRemove, false);
if (index == -1) return false;
actorToInsert.setPosition(actorToRemove.getX(), actorToRemove.getY());
actorToInsert.setUserObject(actorToRemove.getUserObject());
removeActor(actorToRemove, false);
addActorAt(index, actorToInsert);
return true;
}
}
代码示例来源: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());
}
}
内容来源于网络,如有侵权,请联系作者删除!