Libgdx - Mtx纹理未显示在屏幕上

时间:2014-02-23 22:58:09

标签: java android libgdx

我尝试从mtx flame words example重新创建菜单,但屏幕上没有显示任何内容。资产没有问题,因为我可以将它们与spritebatch一起使用。它几乎是1: 1与示例,我无法弄清问题在哪里。

public class MainMenuScreen extends AbstractScreen implements IScreen{

private MainMenuScreenButtons mainMenuScreenButtons;
public MainMenuScreen(AbstractGame game, String screenName) {
    super(game, screenName);
    // TODO Auto-generated constructor stub
    setUpScreenElements();
    setUpMenu();
}

@Override
public void setUpScreenElements() {
    setOpenGLClearColor(0.1f, 0.1f, 0.1f, 1f);
    setBackgroundTexture(Assets.background);
}

@Override
public void setUpMenu() {
    // TODO Auto-generated method stub
    mainMenuScreenButtons = new MainMenuScreenButtons(MainMenuScreen.this);

}

public MainMenuScreenButtons getMainMenuScreenButtons() {
    return mainMenuScreenButtons;
}

@Override
public void render(float delta) {
    // TODO Auto-generated method stub
    super.render(delta);
}
}

MainMenuScreenButtons

public class MainMenuScreenButtons {
private MainMenuScreen mainMenuScreen;

private Table tableMain;
private Table tableButtons;

private ButtonLight btnPlay;

public MainMenuScreenButtons(MainMenuScreen mainMenuScreen) {
    // TODO Auto-generated constructor stub
    this.mainMenuScreen = mainMenuScreen;
    setUp();
}

public void setUp() {
    // TODO Auto-generated method stub
    tableMain = new Table();
    tableMain.setFillParent(true);
    tableButtons = new Table();


            btnPlay = new ButtonLight(310,130,Assets.buttons,true);

            UtilsOrigin.setActorOrigin(btnPlay, Origin.CENTER);

            tableButtons.add(btnPlay).row();
            tableButtons.center();
            tableMain.add(tableButtons).center();
            mainMenuScreen.getStage().addActor(tableMain);
}

}

1 个答案:

答案 0 :(得分:1)

尝试使用gdx纹理包装器https://code.google.com/p/libgdx-texturepacker-gui/ 然后将扩展名更改为文本并删除第一个空白并清理项目。