Created
October 28, 2016 07:29
-
-
Save drojf/69070c69ef3da492ae754b797e3e4363 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mygdx.game; | |
import com.badlogic.gdx.ApplicationAdapter; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.graphics.GL20; | |
import com.badlogic.gdx.scenes.scene2d.Stage; | |
import com.badlogic.gdx.scenes.scene2d.ui.*; | |
public class MyGdxGame extends ApplicationAdapter { | |
private Stage stage; | |
private Window window; | |
private Skin skin; | |
public Table get_t(String name, boolean left_aligned, boolean arrow) | |
{ | |
String symbol = "-"; | |
if(arrow) | |
symbol = ">"; | |
Table t = new Table(); | |
if(left_aligned) { | |
t.add(new TextButton(symbol, skin)); | |
t.add(new Label(name, skin)); | |
} | |
else | |
{ | |
t.add(new Label(name, skin)); | |
t.add(new TextButton(symbol, skin)); | |
} | |
return t; | |
} | |
@Override | |
public void create () { | |
stage = new Stage(); | |
Gdx.input.setInputProcessor(stage); | |
skin = new Skin(Gdx.files.internal("uiskin.json")); | |
Table c1 = new Table(); | |
c1.add(get_t("c1", true, true)); | |
Table c2 = new Table(); | |
c2.add(get_t("c2", false, true)); | |
c2.row(); | |
c2.add(get_t("c222", false, true)); | |
Table c3 = new Table(); | |
c3.add(get_t("c3", true, false)); | |
c3.row(); | |
c3.add(get_t("c3333", true, false)); | |
Table c4 = new Table(); | |
c4.add(get_t("c4", false, false)); | |
c4.row(); | |
c4.add(get_t("c44444", false, false)); | |
window = new Window("test window",skin); | |
window.setDebug(true); | |
//Table.setTouchable(Enabled) | |
//needed for drag? | |
//window.setFillParent(true); | |
window.add(c1); | |
window.add(new Container()).expand(); | |
window.add(c2); | |
window.row(); | |
window.add(c3); | |
window.add(new Container()).expand(); | |
window.add(c4); | |
window.setX(300); | |
window.setY(300); | |
stage.addActor(window); | |
System.out.println(window.getPrefWidth()); | |
} | |
@Override | |
public void resize (int width, int height) { | |
stage.getViewport().update(width, height, true); | |
} | |
@Override | |
public void render () { | |
//Gdx.gl.glClearColor(1, 0, 0, 1); | |
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); | |
stage.act(Gdx.graphics.getDeltaTime()); | |
stage.draw(); | |
//batch.begin(); | |
//batch.draw(img, 0, 0); | |
//batch.end(); | |
} | |
@Override | |
public void dispose () { | |
//batch.dispose(); | |
stage.dispose(); | |
//img.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment