【发布时间】:2014-05-21 11:11:34
【问题描述】:
我正在尝试在 LibGDX 中制作菜单。 但是我无法在屏幕上绘制 Button 或 textButton 。 我尝试使用测试皮肤。 我试着用一张桌子。 我尝试使用按钮和文本按钮。
图像很好,因为它可以在使用 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的原因?
【问题讨论】:
标签: opengl libgdx opengl-3 scene2d