use of com.badlogic.gdx.scenes.scene2d.Stage in project Entitas-Java by Rubentxu.
the class GameSceneState method loadResources.
@Override
public void loadResources() {
this.skinManager = engine.getManager(SMGUIManager.class);
this.assetsManager = engine.getManager(BaseAssetsManager.class);
guiFactory = new GuiFactory(assetsManager, skin);
bodyBuilder = new BodyBuilder();
this.stage = new Stage();
stage.clear();
stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
Gdx.input.setInputProcessor(stage);
Gdx.app.log("Menu", "LoadResources");
assetsManager.loadTextureAtlas(SPRITE_ATLAS);
assetsManager.finishLoading();
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class BaseG3dHudTest method createHUD.
protected void createHUD() {
hud = new Stage(new ScalingViewport(Scaling.fit, PREF_HUDWIDTH, PREF_HUDHEIGHT));
hudWidth = hud.getWidth();
hudHeight = hud.getHeight();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
final List<String> modelsList = new List(skin);
modelsList.setItems(models);
modelsList.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (!modelsWindow.isCollapsed() && getTapCount() == 2) {
onModelClicked(modelsList.getSelected());
modelsWindow.collapse();
}
}
});
modelsWindow = addListWindow("Models", modelsList, 0, -1);
fpsLabel = new Label("FPS: 999", skin);
hud.addActor(fpsLabel);
gridCheckBox = new CheckBox("Show grid", skin);
gridCheckBox.setChecked(showAxes);
gridCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
showAxes = gridCheckBox.isChecked();
}
});
gridCheckBox.setPosition(hudWidth - gridCheckBox.getWidth(), 0);
hud.addActor(gridCheckBox);
rotateCheckBox = new CheckBox("Rotate", skin);
rotateCheckBox.setChecked(true);
rotateCheckBox.setPosition(hudWidth - rotateCheckBox.getWidth(), gridCheckBox.getHeight());
hud.addActor(rotateCheckBox);
moveCheckBox = new CheckBox("Move", skin);
moveCheckBox.setChecked(false);
moveCheckBox.setPosition(hudWidth - moveCheckBox.getWidth(), rotateCheckBox.getTop());
hud.addActor(moveCheckBox);
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class ControllersTest method setupUi.
private void setupUi() {
// setup a tiny ui with a console and a clear button.
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
stage = new Stage();
ui = new Table();
ui.setSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
console = new List(skin);
scrollPane = new ScrollPane(console);
scrollPane.setScrollbarsOnTop(true);
TextButton clear = new TextButton("Clear", skin);
ui.add(scrollPane).expand(true, true).fill();
ui.row();
ui.add(clear).expand(true, false).fill();
stage.addActor(ui);
clear.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
clear();
}
});
Gdx.input.setInputProcessor(stage);
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class ProgressBar method act.
@Override
public void act(float delta) {
super.act(delta);
if (animateTime > 0) {
animateTime -= delta;
Stage stage = getStage();
if (stage != null && stage.getActionsRequestRendering())
Gdx.graphics.requestRendering();
}
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class TextField method next.
/** 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;
while (true) {
current.getParent().localToStageCoordinates(tmp1.set(getX(), getY()));
TextField textField = current.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 = current.findNextTextField(getStage().getActors(), null, tmp2, tmp1, up);
}
if (textField == null) {
Gdx.input.setOnscreenKeyboardVisible(false);
break;
}
if (stage.setKeyboardFocus(textField))
break;
current = textField;
}
}
Aggregations