Answer the question
In order to leave comments, you need to log in
What is the correct way to use Screen in libGDX?
I read an article on libgdx.ru about the Screen interface, I can’t understand how it works (here is the article itself www.libgdx.ru/2013/09/extending-simple-game.html).
According to the article, we write the following class:
public class Drop extends Game {
SpriteBatch batch;
BitmapFont font;
public void create() {
batch = new SpriteBatch();
// libGDX по умолчанию использует Arial шрифт.
font = new BitmapFont();
this.setScreen(new MainMenuScreen(this));
}
public void render() {
super.render(); // важно!
}
public void dispose() {
batch.dispose();
font.dispose();
}
}
public class myGdxGame extends ApplicationAdapter {
public void create () {
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
}
}
Answer the question
In order to leave comments, you need to log in
It's simple, change it. As I understand it, you generate the screen in another class. Then in the main you should just use that creation class. That is, declare that you are creating a screen.
To understand in more detail, I advise the article:
LibgdxTutorial
At one time, it helped me very well!
This is roughly what should be left in the main.
@Override
public void create() {
setScreen(new GameScreen()); //только название поставить следует своё )
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question