use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class Widget method validate.
public void validate() {
if (!layoutEnabled)
return;
Group parent = getParent();
if (fillParent && parent != null) {
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = stage.getHeight();
} else {
parentWidth = parent.getWidth();
parentHeight = parent.getHeight();
}
setSize(parentWidth, parentHeight);
}
if (!needsLayout)
return;
needsLayout = false;
layout();
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class WidgetGroup method validate.
public void validate() {
if (!layoutEnabled)
return;
Group parent = getParent();
if (fillParent && parent != null) {
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = stage.getHeight();
} else {
parentWidth = parent.getWidth();
parentHeight = parent.getHeight();
}
if (getWidth() != parentWidth || getHeight() != parentHeight) {
setWidth(parentWidth);
setHeight(parentHeight);
invalidate();
}
}
if (!needsLayout)
return;
needsLayout = false;
layout();
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class Window method keepWithinStage.
void keepWithinStage() {
if (!keepWithinStage)
return;
Stage stage = getStage();
Camera camera = stage.getCamera();
if (camera instanceof OrthographicCamera) {
OrthographicCamera orthographicCamera = (OrthographicCamera) camera;
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, getY(Align.right), Align.right);
if (getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, getY(Align.left), Align.left);
if (getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
if (getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
} else if (getParent() == stage.getRoot()) {
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX() < 0)
setX(0);
if (getRight() > parentWidth)
setX(parentWidth - getWidth());
if (getY() < 0)
setY(0);
if (getTop() > parentHeight)
setY(parentHeight - getHeight());
}
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class DragNDropTest method create.
@Override
public void create() {
BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
stage = new Stage();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Gdx.input.setInputProcessor(stage);
root = new Table();
root.setFillParent(true);
root.align(Align.left | Align.top);
stage.addActor(root);
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class ActionSequenceTest method create.
@Override
public void create() {
stage = new Stage();
texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
img = new Image(new TextureRegion(texture));
img.setSize(100, 100);
img.setOrigin(50, 50);
img.setPosition(100, 100);
img2 = new Image(new TextureRegion(texture));
img2.setSize(100, 100);
img2.setOrigin(50, 50);
img2.setPosition(100, 100);
img3 = new Image(new TextureRegion(texture));
img3.setSize(100, 100);
img3.setOrigin(50, 50);
img3.setPosition(100, 100);
stage.addActor(img);
stage.addActor(img2);
stage.addActor(img3);
img.addAction(sequence());
img2.addAction(parallel(sequence(), moveBy(100, 0, 1)));
img3.addAction(sequence(parallel(moveBy(100, 200, 2)), Actions.run(this)));
}
Aggregations