本文整理了Java中com.badlogic.gdx.scenes.scene2d.Actor.setX()
方法的一些代码示例,展示了Actor.setX()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Actor.setX()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Actor
类名称:Actor
方法名:setX
[英]Sets the x position using the specified Align. Note this may set the position to non-integer coordinates.
[中]使用指定的对齐设置x位置。注意,这可能会将位置设置为非整数坐标。
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
// create a stage and a camera controller so we can pan the view.
stage = new Stage();;
camController = new OrthoCamController((OrthographicCamera)stage.getCamera()); // we know it's an ortho cam at this point!
Gdx.input.setInputProcessor(camController);
// load a dummy texture
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
// populate the stage with some actors and groups.
for (int i = 0; i < 5000; i++) {
Actor img = new CullableActor("img" + i, texture, (OrthographicCamera)stage.getCamera());
img.setX((float)Math.random() * 480 * 10);
img.setY((float)Math.random() * 320 * 10);
stage.addActor(img);
}
// we also want to output the number of visible actors, so we need a SpriteBatch and a BitmapFont
batch = new SpriteBatch();
font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
代码示例来源:origin: dingjibang/GDX-RPG
public TypedGdxQuery<T> x(float x){
t.setX((int)x);
return this;
}
代码示例来源:origin: Var3D/var3dframe
public UI<T> setX(float x) {
t.setX(x);
return this;
}
代码示例来源:origin: dingjibang/GDX-RPG
public GdxQuery x(float x){
for(Actor actor:list())
actor.setX((int)x);
return this;
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
private void setActorPos (Actor actor, float pos) {
if (isVertical) {
actor.setY(pos);
} else {
actor.setX(pos);
}
}
代码示例来源:origin: Var3D/var3dframe
public UI<T> setX(Actor actor) {
t.setX(actor.getX());
return this;
}
代码示例来源:origin: lycying/c2d-engine
/**aligin the Actor to the center of the screen */
public static void centerActor(final Actor actor){
actor.setX( ( Engine.getWidth() - actor.getWidth() )/2 );
actor.setY( ( Engine.getHeight() - actor.getHeight() )/2 );
}
}
代码示例来源: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: dingjibang/GDX-RPG
public GdxQuery center(boolean setPosition) {
for(Actor actor : list()){
actor.setOrigin(Align.center);
if(actor instanceof Image)
((Image)actor).setAlign(Align.center);
if(actor instanceof Label)
((Label) actor).setAlignment(Align.center);
if(setPosition){
actor.setX(actor.getX() - actor.getWidth() / 2);
actor.setY(actor.getY() - actor.getHeight() / 2);
}
}
return this;
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
child.setWidth(Math.abs(getAnchoredX(toLeft) - (getAnchoredX(toRight) + getScaledWidth(toRight))));
} else if (toLeft != null) {
child.setX(getAnchoredX(toLeft) - getScaledWidth(child));
child.setX(getAnchoredX(toRight) + getScaledWidth(toRight));
if (alignInParent == Align.bottomLeft) return;
if ((alignInParent & Align.center) == Align.center) {
child.setX((parentW - getScaledWidth(child)) * 0.5f);
child.setY((parentH - getScaledHeight(child)) * 0.5f);
child.setX(0);
if (toLeft != null) {
child.setWidth(getAnchoredX(toLeft));
child.setWidth(parentW - (getAnchoredX(toRight) + getScaledWidth(toRight)));
child.setX(parentW - getScaledWidth(child));
代码示例来源:origin: kotcrab/vis-ui
/**
* Makes sures that actor will be fully visible in stage. If it's necessary actor position will be changed to fit it
* on screen.
*/
public static void keepWithinStage (Stage stage, Actor actor) {
//taken from scene2d.ui Window
Camera camera = stage.getCamera();
if (camera instanceof OrthographicCamera) {
OrthographicCamera orthographicCamera = (OrthographicCamera) camera;
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (actor.getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
actor.setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, actor.getY(Align.right), Align.right);
if (actor.getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
actor.setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, actor.getY(Align.left), Align.left);
if (actor.getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
actor.setPosition(actor.getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
if (actor.getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
actor.setPosition(actor.getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
} else if (actor.getParent() == stage.getRoot()) {
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (actor.getX() < 0) actor.setX(0);
if (actor.getRight() > parentWidth) actor.setX(parentWidth - actor.getWidth());
if (actor.getY() < 0) actor.setY(0);
if (actor.getTop() > parentHeight) actor.setY(parentHeight - actor.getHeight());
}
}
}
代码示例来源:origin: langurmonkey/gaiasky
float parentHeight = stage.getHeight();
if (actor.getX() < 0)
actor.setX(0);
if (actor.getRight() > parentWidth)
actor.setX(parentWidth - actor.getWidth());
if (actor.getY() < 0)
actor.setY(0);
代码示例来源:origin: moribitotech/MTX
actorToBePositioned.setX((as_XW / 2.0f) - atp_W / 2.0f);
actorToBePositioned.setY((as_YH / 2.0f) - atp_H / 2.0f);
break;
内容来源于网络,如有侵权,请联系作者删除!