本文整理了Java中com.badlogic.gdx.scenes.scene2d.Stage.getActors()
方法的一些代码示例,展示了Stage.getActors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stage.getActors()
方法的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.Stage
类名称:Stage
方法名:getActors
[英]Returns the root's child actors.
[中]返回根的子角色。
代码示例来源:origin: libgdx/libgdx
public void render () {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.draw();
// check how many actors are visible.
Array<Actor> actors = stage.getActors();
int numVisible = 0;
for (int i = 0; i < actors.size; i++) {
numVisible += ((CullableActor)actors.get(i)).visible ? 1 : 0;
}
batch.begin();
font.draw(batch, "Visible: " + numVisible + ", fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
batch.end();
}
代码示例来源:origin: libgdx/libgdx
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
* @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */
public void next (boolean up) {
Stage stage = getStage();
if (stage == null) return;
TextField current = this;
Vector2 currentCoords = current.getParent().localToStageCoordinates(tmp2.set(current.getX(), current.getY()));
Vector2 bestCoords = tmp1;
while (true) {
TextField textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up);
if (textField == null) { // Try to wrap around.
if (up)
currentCoords.set(Float.MIN_VALUE, Float.MIN_VALUE);
else
currentCoords.set(Float.MAX_VALUE, Float.MAX_VALUE);
textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up);
}
if (textField == null) {
Gdx.input.setOnscreenKeyboardVisible(false);
break;
}
if (stage.setKeyboardFocus(textField)) {
textField.selectAll();
break;
}
current = textField;
currentCoords.set(bestCoords);
}
}
代码示例来源:origin: libgdx/libgdx
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
* @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */
public void next (boolean up) {
Stage stage = getStage();
if (stage == null) return;
TextField current = this;
Vector2 currentCoords = current.getParent().localToStageCoordinates(tmp2.set(current.getX(), current.getY()));
Vector2 bestCoords = tmp1;
while (true) {
TextField textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up);
if (textField == null) { // Try to wrap around.
if (up)
currentCoords.set(Float.MIN_VALUE, Float.MIN_VALUE);
else
currentCoords.set(Float.MAX_VALUE, Float.MAX_VALUE);
textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up);
}
if (textField == null) {
Gdx.input.setOnscreenKeyboardVisible(false);
break;
}
if (stage.setKeyboardFocus(textField)) {
textField.selectAll();
break;
}
current = textField;
currentCoords.set(bestCoords);
}
}
代码示例来源:origin: libgdx/libgdx
Array<Actor> actors = stage.getActors();
int len = actors.size;
if (rotateSprites) {
代码示例来源:origin: kotcrab/vis-ui
/**
* Removes every instance of {@link PopupMenu} form {@link Stage} actors.
* <p>
* Generally called from {@link ApplicationListener#resize(int, int)} to remove menus on resize event.
*/
public static void removeEveryMenu (Stage stage) {
for (Actor actor : stage.getActors()) {
if (actor instanceof PopupMenu) {
PopupMenu menu = (PopupMenu) actor;
menu.removeHierarchy();
}
}
}
代码示例来源:origin: langurmonkey/gaiasky
/**
* Removes every instance of {@link ContextMenu} form {@link Stage} actors.
* <p>
* Generally called from {@link ApplicationListener#resize(int, int)} to remove menus on resize event.
*/
public static void removeAll(Stage stage) {
for (Actor actor : stage.getActors()) {
if (actor instanceof ContextMenu) {
ContextMenu menu = (ContextMenu) actor;
menu.removeHierarchy();
}
}
}
代码示例来源:origin: langurmonkey/gaiasky
public void display() {
if (!stage.getActors().contains(me, true))
stage.addActor(me);
}
代码示例来源:origin: langurmonkey/gaiasky
public void display() {
if (!stage.getActors().contains(me, true))
stage.addActor(me);
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
@Override
public void act(float delta) {
super.act(delta);
if (getStage().getActors().get(getStage().getActors().size - 1) != this)
toFront();
}
代码示例来源:origin: dingjibang/GDX-RPG
@SuppressWarnings("rawtypes")
public GdxQuery add(Object... a) {
for (Object obj: a)
if(obj instanceof TypedGdxQuery)
list().add(((TypedGdxQuery)obj).get());
else if(obj instanceof Actor)
list().add((Actor)obj);
else if(obj instanceof Cell<?>)
list().add(((Cell<?>)obj).getActor());
// else if(obj instanceof ButtonGroup)
// for(Button button:((ButtonGroup)obj).getButtons())
// getItems().add(button);
else if(obj instanceof Stage)
for(Actor actor:((Stage)obj).getActors())
list().add(actor);
else if(obj instanceof GdxQuery)
list().addAll(((GdxQuery)obj).list());
else if(obj instanceof Collection)
for(Object col:(Collection<?>)obj)
add(col);
else if(obj instanceof Array)
for(Object col:(Array<?>)obj)
add(col);
return this;
}
代码示例来源:origin: kotcrab/vis-editor
@Override
public boolean keyDown (InputEvent event, int keycode) {
if (keycode == Keys.F12) {
debug = !debug;
root.setDebug(debug, true);
for (Actor actor : stage.getActors()) {
if (actor instanceof Group) {
Group group = (Group) actor;
group.setDebug(debug, true);
}
}
return true;
}
return false;
}
});
代码示例来源:origin: langurmonkey/gaiasky
public void detach() {
dialogWindow = createWindow(labelText, content, skin, stage, lastx, lasty);
// Display
if (!stage.getActors().contains(dialogWindow, true))
stage.addActor(dialogWindow);
expandIcon.setChecked(false);
expandIcon.setDisabled(true);
detachIcon.setDisabled(true);
}
代码示例来源:origin: langurmonkey/gaiasky
public void display() {
if (!gui.getGuiStage().getActors().contains(me, true))
gui.getGuiStage().addActor(this);
gui.getGuiStage().setKeyboardFocus(searchInput);
}
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
public static void setConsole(Console console) {
EditorLogger.console = console;
EditorLogger.console.setDisplayKeyID(Keys.F1);
console.setMaxEntries(1000);
final Stage s = (Stage) console.getInputProcessor();
final Actor actor = s.getActors().items[0];
actor.addListener(new InputListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
if (toActor == null) {
s.setScrollFocus(null);
}
}
});
console.setCommandExecutor(new EditorCommandExecutor());
}
}
代码示例来源:origin: bladecoder/bladecoder-adventure-engine
private static void add(Stage stage, String text) {
msg.clearActions();
msg.setText(text);
GlyphLayout textLayout = new GlyphLayout();
textLayout.setText(msg.getStyle().font, text, Color.BLACK, stage.getWidth() * .8f, Align.center, true);
msg.setSize(textLayout.width + textLayout.height, textLayout.height + textLayout.height * 2);
if (!stage.getActors().contains(msg, true))
stage.addActor(msg);
msg.setPosition(Math.round((stage.getWidth() - msg.getWidth()) / 2),
Math.round((stage.getHeight() - msg.getHeight()) / 2));
msg.invalidate();
}
代码示例来源:origin: kotcrab/vis-ui
/**
* Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
* @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest.
*/
public void next (boolean up) {
Stage stage = getStage();
if (stage == null) return;
getParent().localToStageCoordinates(tmp1.set(getX(), getY()));
VisTextField textField = findNextTextField(stage.getActors(), null, tmp2, tmp1, up);
if (textField == null) { // Try to wrap around.
if (up)
tmp1.set(Float.MIN_VALUE, Float.MIN_VALUE);
else
tmp1.set(Float.MAX_VALUE, Float.MAX_VALUE);
textField = findNextTextField(getStage().getActors(), null, tmp2, tmp1, up);
}
if (textField != null) {
textField.focusField();
textField.setCursorPosition(textField.getText().length());
} else
Gdx.input.setOnscreenKeyboardVisible(false);
}
代码示例来源:origin: langurmonkey/gaiasky
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
* @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */
public void next(boolean up) {
Stage stage = getStage();
if (stage == null)
return;
getParent().localToStageCoordinates(tmp1.set(getX(), getY()));
TextField textField = findNextTextField(stage.getActors(), null, tmp2, tmp1, up);
if (textField == null) { // Try to wrap around.
if (up)
tmp1.set(Float.MIN_VALUE, Float.MIN_VALUE);
else
tmp1.set(Float.MAX_VALUE, Float.MAX_VALUE);
textField = findNextTextField(getStage().getActors(), null, tmp2, tmp1, up);
}
if (textField != null)
stage.setKeyboardFocus(textField);
else
Gdx.input.setOnscreenKeyboardVisible(false);
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
* @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */
public void next (boolean up) {
Stage stage = getStage();
if (stage == null) return;
TextField current = this;
Vector2 currentCoords = current.getParent().localToStageCoordinates(tmp2.set(current.getX(), current.getY()));
Vector2 bestCoords = tmp1;
while (true) {
TextField textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up);
if (textField == null) { // Try to wrap around.
if (up)
currentCoords.set(Float.MIN_VALUE, Float.MIN_VALUE);
else
currentCoords.set(Float.MAX_VALUE, Float.MAX_VALUE);
textField = current.findNextTextField(stage.getActors(), null, bestCoords, currentCoords, up);
}
if (textField == null) {
Gdx.input.setOnscreenKeyboardVisible(false);
break;
}
if (stage.setKeyboardFocus(textField)) {
textField.selectAll();
break;
}
current = textField;
currentCoords.set(bestCoords);
}
}
代码示例来源:origin: kotcrab/vis-editor
@Override
public void resize (int width, int height) {
if (width == 0 && height == 0) return; //see https://github.com/libgdx/libgdx/issues/3673#issuecomment-177606278
stage.getViewport().update(width, height, true);
PopupMenu.removeEveryMenu(stage);
WindowResizeEvent resizeEvent = new WindowResizeEvent();
for (Actor actor : stage.getActors()) {
actor.fire(resizeEvent);
}
}
内容来源于网络,如有侵权,请联系作者删除!