本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.getRoot()
方法的一些代码示例,展示了Stage.getRoot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.getRoot()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:getRoot
[英]Returns the root group which holds all actors in the stage.
[中]返回包含舞台中所有演员的根组。
代码示例来源:origin: libgdx/libgdx
public Target (Actor actor) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
this.actor = actor;
Stage stage = actor.getStage();
if (stage != null && actor == stage.getRoot())
throw new IllegalArgumentException("The stage root cannot be a drag and drop target.");
}
代码示例来源:origin: libgdx/libgdx
public Target (Actor actor) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
this.actor = actor;
Stage stage = actor.getStage();
if (stage != null && actor == stage.getRoot())
throw new IllegalArgumentException("The stage root cannot be a drag and drop target.");
}
代码示例来源:origin: libgdx/libgdx
private void focusChanged (FocusEvent event) {
Stage stage = getStage();
if (isModal && stage != null && stage.getRoot().getChildren().size > 0
&& stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor.
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this)
&& !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus)))
event.cancel();
}
}
};
代码示例来源:origin: libgdx/libgdx
private void focusChanged (FocusEvent event) {
Stage stage = getStage();
if (isModal && stage != null && stage.getRoot().getChildren().size > 0
&& stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor.
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this)
&& !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus)))
event.cancel();
}
}
};
代码示例来源:origin: libgdx/libgdx
@Override
public void create () {
texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
stage = new Stage();
for (int i = 0; i < 100; i++) {
Image img = new Image(new TextureRegion(texture));
img.setX((float)Math.random() * 480);
img.setY((float)Math.random() * 320);
img.getColor().a = (float)Math.random() * 0.5f + 0.5f;
stage.addActor(img);
}
stage.getRoot().addAction(forever(sequence(fadeOut(3), fadeIn(3))));
}
代码示例来源:origin: libgdx/libgdx
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();
}
代码示例来源:origin: libgdx/libgdx
float minHeight = getMinHeight(), maxHeight = getMaxHeight();
Stage stage = getStage();
boolean clampPosition = keepWithinStage && getParent() == stage.getRoot();
代码示例来源:origin: libgdx/libgdx
float minHeight = getMinHeight(), maxHeight = getMaxHeight();
Stage stage = getStage();
boolean clampPosition = keepWithinStage && getParent() == stage.getRoot();
代码示例来源:origin: libgdx/libgdx
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();
}
代码示例来源:origin: libgdx/libgdx
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = stage.getHeight();
代码示例来源:origin: libgdx/libgdx
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = stage.getHeight();
代码示例来源:origin: libgdx/libgdx
public void keepWithinStage () {
if (!keepWithinStage) return;
Stage stage = getStage();
if (stage == null) return;
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());
}
}
代码示例来源:origin: libgdx/libgdx
public void keepWithinStage () {
if (!keepWithinStage) return;
Stage stage = getStage();
if (stage == null) return;
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());
}
}
代码示例来源:origin: libgdx/libgdx
stage.act(Gdx.graphics.getDeltaTime());
stage.getBatch().disableBlending();
Group root = stage.getRoot();
Array<Actor> actors = root.getChildren();
代码示例来源:origin: com.badlogicgames.gdx/gdx
public Target (Actor actor) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
this.actor = actor;
Stage stage = actor.getStage();
if (stage != null && actor == stage.getRoot())
throw new IllegalArgumentException("The stage root cannot be a drag and drop target.");
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
public void setStage(Stage stage) {
this.stage = stage;
screenHeight = (int) stage.getHeight();
ignoreFocusChangeActorsList = new HashSet<String>();
addFocusChangedListenerToStage();
initialYCoordinateMap.clear();
for(Actor actor : stage.getRoot().getChildren()) {
initialYCoordinateMap.put(actor, actor.getY());
}
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
private void focusChanged (FocusEvent event) {
Stage stage = getStage();
if (isModal && stage != null && stage.getRoot().getChildren().size > 0
&& stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor.
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this)
&& !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus)))
event.cancel();
}
}
};
代码示例来源:origin: manuelbua/uracer-kotd
private void focusChanged (FocusEvent event) {
Stage stage = getStage();
if (isModal && stage != null && stage.getRoot().getChildren().size > 0
&& stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor.
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this)) event.cancel();
}
}
});
代码示例来源:origin: kotcrab/vis-ui
private void focusChanged (FocusEvent event) {
Stage stage = getStage();
if (isModal() && stage != null && stage.getRoot().getChildren().size > 0
&& stage.getRoot().getChildren().peek() == VisDialog.this) { // Dialog is top most actor.
Actor newFocusedActor = event.getRelatedActor();
if (newFocusedActor != null && !newFocusedActor.isDescendantOf(VisDialog.this)) event.cancel();
}
}
};
代码示例来源:origin: langurmonkey/gaiasky
@Override
public void expandGuiComponent(String name) {
IGui gui = GaiaSky.instance.mainGui;
ControlsWindow controls = (ControlsWindow) gui.getGuiStage().getRoot()
.findActor(I18n.bundle.get("gui.controlpanel"));
controls.getCollapsiblePane(name).expandPane();
}
内容来源于网络,如有侵权,请联系作者删除!