0

Только начал осваивать libgdx, наскребал несколько статей по созданию меню и застрял на таком моменте, что приложение не запускается("Unfortunately, has stopped"). Код прилагается,я так понимаю, ошибка кроется там, хотел бы разобраться в проблеме, класс меню:

public class MenuScreen implements Screen {
FifkaFuferyu game;
TextButton switchFifer, switchInfo;
Skin skin;
private Label.LabelStyle labelStyle;
private Table table;
Stage stage;
Image img;

public MenuScreen(final FifkaFuferyu game) {
    this.game = game;

    stage = new Stage(new ScreenViewport());
    skin = new Skin(Gdx.files.internal("skin/rusty-robot-ui.json"));
    TextureAtlas buttonAtlas = new TextureAtlas(Gdx.files.internal("skin/rusty-robot-ui.atlas"));
    skin.addRegions(buttonAtlas);
    TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
    textButtonStyle.font = game.font;
    textButtonStyle.up = skin.getDrawable("button");
    textButtonStyle.down = skin.getDrawable("button-pressed");
    textButtonStyle.checked = skin.getDrawable("button");
labelStyle = new Label.LabelStyle();
labelStyle.font = game.font;
table = new Table();
table.setFillParent(true);

switchFifer = new TextButton("FiferHunt", textButtonStyle);
switchFifer.addListener(new ClickListener() {
    @Override
    public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
        Gdx.input.vibrate(20);
        return true;
    }



    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
        game.setScreen(new FiferHunt(game));
        dispose();
    }


});

switchInfo.addListener(new ClickListener(){
    @Override
    public boolean touchDown(InputEvent event, float x, float y, int 
pointer, int button) {
        Gdx.input.vibrate(20);
        return true;
    };
    @Override
    public void touchUp(InputEvent event, float x, float y, int pointer, 
int button) {
        game.setScreen(new InfoScreen(game));
        dispose();
    }
});

table.add(switchFifer);
table.row();
table.add(switchInfo);
stage.addActor(table);

Gdx.input.setInputProcessor(stage);
Gdx.input.setCatchBackKey(true);
}
@Override
public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);


    stage.act(delta);
    stage.draw();
}

Классы в которые можно перейти пусты, лишь принимают аргумент основного класса, сам основной класс:

public class FifkaFuferyu extends Game {
    public BitmapFont font, levels;
    private static final String FONT_CHARACTERS = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789][_!$%#@|\\/?-+=()*&.;,{}\"´`'<>";

@Override
public void create() {


    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/russoone.ttf"));
    FreeTypeFontGenerator.FreeTypeFontParameter param = new FreeTypeFontGenerator.FreeTypeFontParameter();
    param.size = Gdx.graphics.getHeight() / 18;
    param.characters = FONT_CHARACTERS;
    font = generator.generateFont(param);
    param.size = Gdx.graphics.getHeight() / 20;
    levels = generator.generateFont(param);
    font.setColor(Color.WHITE);
    levels.setColor(Color.WHITE);
    generator.dispose();

}
    @Override
    public void render() {
        this.setScreen(new MenuScreen(this));
    }

2 Answers2

0

точно не знаю но попробуй это this.setScreen(new MenuScreen(this)); поставить не в render(), а в create() и в render() поставь super()

Zaigard
  • 11
  • 4
0

Не совсем понял, что такое стектрейс, но сегодня еще обнаружил 1 предупреждение, к сожалению полный нуб в подобном: Warning:[options] bootstrap class path not set in conjunction with -source 1.6

  • Если коротко то это то сообщение которое пишется при сбое/ошибке и не только, а именно последовательность вызовов методов. Подробнее тут: https://ru.stackoverflow.com/questions/510755/%d0%a7%d1%82%d0%be-%d1%82%d0%b0%d0%ba%d0%be%d0%b5-stack-trace-%d0%b8-%d0%ba%d0%b0%d0%ba-%d1%81-%d0%b5%d0%b3%d0%be-%d0%bf%d0%be%d0%bc%d0%be%d1%89%d1%8c%d1%8e-%d0%bd%d0%b0%d1%85%d0%be%d0%b4%d0%b8%d1%82%d1%8c-%d0%be%d1%88%d0%b8%d0%b1%d0%ba%d0%b8-%d0%bf%d1%80%d0%b8-%d1%80%d0%b0%d0%b7%d1%80%d0%b0%d0%b1%d0%be%d1%82%d0%ba%d0%b5-%d0%bf%d1%80%d0%b8%d0%bb%d0%be%d0%b6 – Mark Cain Jan 24 '21 at 23:44