我正在尝试为我正在制作的游戏选项做一个菜单
对于这个屏幕,我使用tablelayout但我无法使用它。
我得到的只是黑屏
看看自己:
package com.me.mygdxgame;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.CheckBox;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
public class BlueToothOptionScreen implements Screen{
final Stage stage;
Skin skin;
boolean hote = false;
Table table;
public BlueToothOptionScreen() {
this.stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getWidth(), true);
FileHandle skinFile1 = Gdx.files.internal("uiskin.json");
skin = new Skin(skinFile1);
}
@Override
public void render(float delta) {
stage.act(delta);
Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );
stage.draw();
Table.drawDebug(stage);
}
@Override
public void resize(int width, int height) {
stage.setViewport(width, height, true);
}
@Override
public void show() {
Gdx.input.setInputProcessor( stage );
table = new Table(skin);
stage.addActor(table);
table.setFillParent(true);
table.defaults().spaceBottom(30);
table.add("Options").colspan(3);
final CheckBox hoteCheckBox = new CheckBox( "", skin );
hoteCheckBox.setChecked(true);
hoteCheckBox.addListener(new ChangeListener() {
@Override
public void changed(
ChangeEvent event,
Actor actor )
{
boolean enabled = hoteCheckBox.isChecked();
hote = enabled;
}
} );
table.row();
table.add("Hote");
table.add(hoteCheckBox);
}
}
如果你能帮助我,我会很高兴。