Android libgdx中的Textbutton和纹理图谱
我有一个纹理图集的文本按钮Android libgdx中的Textbutton和纹理图谱,android,button,timer,libgdx,Android,Button,Timer,Libgdx,我有一个纹理图集的文本按钮 TextButton.TextButtonStyle style = new TextButton.TextButtonStyle(); style.up = buttonSkin.getDrawable("buttonup"); style.down = buttonSkin.getDrawable("buttondown"); style.font = font; 当我按下退出按钮上的按钮时,我得到了代码 Gd
TextButton.TextButtonStyle style = new TextButton.TextButtonStyle();
style.up = buttonSkin.getDrawable("buttonup");
style.down = buttonSkin.getDrawable("buttondown");
style.font = font;
当我按下退出按钮上的按钮时,我得到了代码
Gdx.app.exit();
它工作了,我可以看到style.down在按钮事件着陆时。当我在按钮播放中使用它时,我看不到样式。向下。为什么?我试着用计时器
Timer.schedule(new Timer.Task() {
@Override
public void run() {
myGame.setScreen(new GameScreen(myGame));
}
}, 500);
但是游戏屏幕在运行,我看不到按下的按钮。你能告诉我这个问题可能的解决办法吗
编辑:
您发布的代码应该显示一个可以最快获得帮助的代码。否则,在遇到问题之前,您将收到要求越来越多代码的问题。例如,您可能应该显示“播放”按钮的代码,而不是运行游戏屏幕的工作代码?添加了按钮。侦听器…您可以添加实例化
按钮的位置吗?添加了样式和文本按钮的代码以查找解决方案!!!!设置屏幕(新游戏屏幕(myGame));在润色中:()()()()())())()))你。否则,在遇到问题之前,您将收到要求越来越多代码的问题。例如,您可能应该显示“播放”按钮的代码,而不是运行游戏屏幕的工作代码?添加了按钮。侦听器…您可以添加实例化按钮的位置吗?添加了样式和文本按钮的代码以查找解决方案!!!!设置屏幕(新游戏屏幕(myGame));在补强中:(()()()))
button.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
myGame.setScreen(new GameScreen(myGame));
return true;
}
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
}
});
style.up = buttonSkin.getDrawable("buttonup");
style.down = buttonSkin.getDrawable("buttondown");
style.font = font;
button = new TextButton("Play", style);
button.setHeight(300 * scaley);
button.setWidth(800 * scalex);
button.setPosition(Constants.APP_WIDTH / 2 - button.getWidth() / 2, Constants.APP_HEIGHT / 2 + button.getHeight());