0

такая проблема, на эмуляторе такого бага не выявлено, если запускаю на пк т.е DesktopLauncher происходит мерцание экрана , на физическом устройстве также мерцает экран. Класс стартер:

public class Drop extends Game {
Camera cam;
Game game;
SpriteBatch batch;
int tempGameScore = 0;//пеерменная для вывода на экране score
int dropsGatchered = 0;
Preferences preferences;//сохраняем игру

@Override
public void create() {
    batch = new SpriteBatch();
 this.setScreen(new MainMenuScreen(this));



}

@Override
public void render() {

    super.render();


}

@Override
public void dispose() {

    batch.dispose();

}

}

Меню:

public class MainMenuScreen implements Screen, ApplicationListener {

Sprite texture;
final Drop game;

Skin skin;
Stage stage;
OrthographicCamera camera;

ImageButton newGameButton, exit, highScore;
Table table;
ImageButton.ImageButtonStyle btnplayStyle, btnscoreStyle, btnexitStyle;
// Sprite sprite;
//SpriteBatch batch;
private static TextureAtlas atlas, backAtlas;

// Sprite sprite;
//SpriteBatch batch;

@Override
public void create() {


}

public MainMenuScreen(final Drop gam) {
    this.game = gam;

    atlas = new TextureAtlas(Gdx.files.internal("texture/texture.pack"), true);
    backAtlas = new TextureAtlas(Gdx.files.internal("texture/background.pack"), true);
    texture = new Sprite(backAtlas.findRegion("background"));
    skin = new Skin();
    skin.addRegions(atlas);
    table = new Table();

    camera = new OrthographicCamera();

    camera.setToOrtho(false, 800, 480);
    stage = new Stage();
    stage.addActor(table);
    Gdx.input.setInputProcessor(stage);// Make the stage consume events

}

@Override
public void show() {
    table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    btnplayStyle = new ImageButton.ImageButtonStyle();
    btnplayStyle.up = skin.getDrawable("play");//кнопка не нажата
    btnplayStyle.over = skin.getDrawable("play");
    btnplayStyle.down = skin.getDrawable("play"); // кнопка нажата
    newGameButton = new ImageButton(btnplayStyle);
    newGameButton.setSize(300, 200);

    stage.addActor(newGameButton);
    newGameButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            game.setScreen(new GameScreen(game));
        }
    });

    //Button score
    btnscoreStyle = new ImageButton.ImageButtonStyle();
    btnscoreStyle.up = skin.getDrawable("records");//кнопка не нажата
    btnscoreStyle.over = skin.getDrawable("records");
    btnscoreStyle.down = skin.getDrawable("records"); // кнопка нажата
    highScore = new ImageButton(btnscoreStyle);
    highScore.setSize(300, 200);

    stage.addActor(highScore);
    highScore.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {

            game.setScreen(new Score(game) {

            });

        }
    });

    //Button EXIT
    btnexitStyle = new ImageButton.ImageButtonStyle();
    btnexitStyle.up = skin.getDrawable("exit");//кнопка не нажата
    btnexitStyle.over = skin.getDrawable("exit");
    btnexitStyle.down = skin.getDrawable("exit"); // кнопка нажата
    exit = new ImageButton(btnexitStyle);
    exit.setSize(300, 200);

    stage.addActor(exit);
    exit.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            Gdx.app.exit();
        }
    });
    game.batch.begin();
    game.batch.draw(texture, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    game.batch.end();

    table.add(newGameButton).width(400).height(100);
    table.getCell(newGameButton).spaceBottom(30);
    table.row();

    table.add(highScore).width(400).height(100);

    table.getCell(highScore).spaceBottom(30);
    table.row();

    table.add(exit).width(400).height(100);
    table.getCell(exit).spaceBottom(30);
    table.row();

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

@Override
public void render() {

    System.out.println("ичего ен рисуем");
}

@Override
public void resize(int width, int height) {

}

@Override
public void render(float delta) {

}

@Override
public void pause() {

}

@Override
public void resume() {

}

@Override
public void hide() {

}

@Override
public void dispose() {

}

1 ответ 1

2

Всё таки лучше хоть что-то да выводить
например:

Gdx.gl.glClearColor( 1.0f, 1.0f, 1.0f, 1.0f);  
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT );

Иначе мусор может выводиться на реальных устройствах

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.