LibGDXでメニューを作ろうとしています。しかし、ボタンやテキストボタンを画面に描画することはできません。テストスキンを使ってみました。テーブルを使ってみました。ボタンとテキストボタンを使ってみました。
画像はSpriteBatchを使って描画しながら表示でき、フォントもうまく動くので問題ありません。
これは私のコードの一部です。
public class Menu implements Screen {
private Stage stage;
private Skin skin;
private TextButton textButton;
private Game mygame;
private BitmapFont font;
private TextureAtlas atlas;
private SpriteBatch batch;
private TextureRegion test;
public SplashScreen(Game g){
mygame = g;
}
@Override
public void show() {
batch = new SpriteBatch();
stage = new Stage();
stage.clear();
atlas = new TextureAtlas("buttons/bot.pack");
skin = new Skin(atlas);
font = new BitmapFont(Gdx.files.internal("fonts/arialfnt.fnt"),false);
TextButtonStyle buttonStyle = new TextButtonStyle();
buttonStyle.up = skin.getDrawable("button.up");
buttonStyle.over = skin.getDrawable("button.over");
buttonStyle.down = skin.getDrawable("button.down");
buttonStyle.font = font;
textButton = new TextButton("Click here", buttonStyle);
textButton.setPosition(200, 300);
textButton.setHeight(300);
textButton.setWidth(100);
test = atlas.findRegion("button.up"); //Testing the atlas
stage.addActor(textButton);
}
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);
stage.act(delta);
stage.draw(); //DOES NOT WORK
batch.begin();
batch.draw(test, 300, 300); //It works
font.draw(batch, "BLA BLA!", 50, 500); //It works
batch.end();
}
}
これを機能させるための提案はありますか?GL3.0のせいでしょうか?