我正在做一个游戏,我试图在游戏结束时画一个舞台。当我使用旧版本的libgdx时,这很好。当我更新libGdx版本时,我遇到了以下问题。我在gameOver中使用了相同的背景变量gamePlayBG,我在整个游戏中使用它,并每次都重置它。目前,但舞台还没有画。只有gamePlayBG在画画。下面是我的代码:
private void gameOver() {
gameOverStage = new Stage();
Gdx.input.setInputProcessor(gameOverStage);
//gameOverStage.setCamera(camera2);
if (isBackgroundMusicPlaying()) {
game.freePlaySound.stop();
}
StretchViewport viewport = new StretchViewport(480, 853);
gameOverStage.setViewport(viewport);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
gamePlayBG = new Texture(Gdx.files.internal("data/main_bg.png"));
TextureRegionDrawable gameOverBG = new TextureRegionDrawable();
gameOverBG.setRegion(new TextureRegion(new
Texture(Gdx.files.internal("data/bg_gameover.png"))));
Button mainMenuButton = new Button();
ButtonStyle mainMenuStyle = new ButtonStyle();
mainMenuStyle.up = new TextureRegionDrawable(new TextureRegion(new
Texture(Gdx.files.internal("data/home.png"))));
mainMenuButton.setStyle(mainMenuStyle);
mainMenuButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int
pointer, int num) {
if (game.soundBoolean) {
game.objectRemovedSound.play();
}
game.goToMainMenu();
return false;
}
});
TextButton.TextButtonStyle playAgainStyle = new
TextButton.TextButtonStyle();
playAgainStyle.up = new TextureRegionDrawable(new TextureRegion(new
Texture(Gdx.files.internal("data/green.png"))));
playAgainStyle.font = game.scoreFonts;
TextButton playAgainButton = new TextButton("Play Again",
playAgainStyle);
playAgainButton.getLabel().setFontScale(0.70f);
playAgainButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int num) {
restart();
if (game.soundBoolean) {
game.buttonSound.play();
}
return false;
}
});
Button awardsButton = new Button();
ButtonStyle awardsButtonStyle = new ButtonStyle();
awardsButtonStyle.up = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("data/awards.png"))));
awardsButton.setStyle(awardsButtonStyle);
awardsButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int num) {
if (game.soundBoolean) {
game.objectRemovedSound.play();
}
/**
* Put navigation to awards screen here.
*/
return false;
}
});
/**
* Time up label settings
*/
LabelStyle timeUpLabelStyle = new LabelStyle();
timeUpLabelStyle.font = game.greenShadowFont;
Label timeUpLabel = new Label("Time up!", timeUpLabelStyle);
timeUpLabel.setFontScale(1.7f);
/**
* Your Score up label settings
*/
LabelStyle yourScoreLabelStyle = new LabelStyle();
yourScoreLabelStyle.font = game.scoreFonts;
Label yourScoreLabel = new Label("YOUR SCORE IS:", yourScoreLabelStyle);
yourScoreLabel.setFontScale(1.0f);
/**
* Setting current score text
*/
LabelStyle currentScoreLabelStyle = new LabelStyle();
currentScoreLabelStyle.font = game.gameTopFonts;
Label currentScoreLabel = new Label("" + score, currentScoreLabelStyle);
currentScoreLabel.setFontScale(1.3f);
/**
* Time up label settings
*/
LabelStyle yourHighScoreLabelStyle = new LabelStyle();
yourHighScoreLabelStyle.font = game.scoreFonts;
Label yourHighScoreLabel = new Label("YOUR HIGH SCORE:", yourHighScoreLabelStyle);
yourHighScoreLabel.setFontScale(0.8f);
/**
* Setting high score text
*/
LabelStyle highScoreLabelStyle = new LabelStyle();
highScoreLabelStyle.font = game.gameTopFonts;
int highScore = game.prefs.getInteger("highScore", score);
Label highScoreLabel = new Label("" + highScore, highScoreLabelStyle);
highScoreLabel.setFontScale(1.1f);
/**
* Creating tables for buttons, background and labels
*/
Table bgTable = new Table();
Table buttonsTable = new Table();
Table timeUpTable = new Table();
Table yourScoreTable = new Table();
Table yourHighScoreTable = new Table();
Table currentScoreTable = new Table();
Table highScoreTable = new Table();
Image gameOverBGImg = new Image(gameOverBG);
bgTable.add(gameOverBGImg);
bgTable.setFillParent(true);
/**
* Adding score labels to table
*/
timeUpTable.add(timeUpLabel);
yourScoreTable.add(yourScoreLabel);
highScoreTable.add(highScoreLabel);
currentScoreTable.add(currentScoreLabel);
yourHighScoreTable.add(yourHighScoreLabel);
/**
* Assigning alignment/positions to buttons
*/
buttonsTable.add(awardsButton).padRight(20);
buttonsTable.add(playAgainButton).padRight(20);
buttonsTable.add(mainMenuButton);
//gameOverStage.addActor(background);
gameOverStage.addActor(bgTable);
gameOverStage.addActor(buttonsTable);
gameOverStage.addActor(currentScoreTable);
gameOverStage.addActor(highScoreTable);
gameOverStage.addActor(yourScoreTable);
gameOverStage.addActor(yourHighScoreTable);
gameOverStage.addActor(timeUpTable);
buttonsTable.setPosition(260, 175);
timeUpTable.setPosition(260, 580);
yourScoreTable.setPosition(260, 480);
currentScoreTable.setPosition(260, 420);
yourHighScoreTable.setPosition(260, 325);
highScoreTable.setPosition(260, 275);
gameOver = true;
if (score >= highScore) {
game.prefs.putInteger("highScore", score);
game.prefs.flush();
}
}
下面是在时间为零时调用gameOver()方法的render方法:
public void render(float delta) {
// TODO Auto-generated method stub
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
game.batch.begin();
game.batch.setProjectionMatrix(camera2.combined);
game.batch.draw(gamePlayBG, 0, 0);
if (gameOver != true) {
//Log.d("render------------", "render: "+ delta);
progressBar.draw(game.batch, 1);
progressBar.setPosition(115, 700);
progressBar.setHeight(15);
progressBar.setWidth(270);
camera.update();
game.batch.setProjectionMatrix(camera.combined);
if (lineHud.size > 1) {
for (Sprite sprite : this.lineHud) {
sprite.draw(game.batch);
}
}
for (int i = 0; i < gameObjects.size; i++) {
gameObjects.get(i).draw(game.batch);
}
for (Sprite sprite : this.scoreHud) {
sprite.draw(game.batch);
}
if (stopGameObjects) {
game.batch.setProjectionMatrix(camera2.combined);
levelupButton.draw(game.batch, 1);
/* levelUp.draw(game.batch);
game.levelUpFont.drawMultiLine(game.batch, "LEVEL " + (baseLevel + 1),
(gamePlayBG.getWidth() / 2) - 55,
(gamePlayBG.getHeight() / 2) + 35);
game.levelUpFont.drawMultiLine(game.batch, "KEEP GOING",
(gamePlayBG.getWidth() / 2) - 90,
gamePlayBG.getHeight() / 2);*/
/*game.levelUpFont.drawMultiLine(game.batch,"KEEP GOING",
(gamePlayBG.getWidth() / 2) - 50,
(gamePlayBG.getHeight() / 2) + 50);*/
}
game.tweenManager.update(delta);
game.batch.end();
update(delta);
game.batch.setProjectionMatrix(camera2.combined);
if (gameOver == true) {
this.gameOverStage.act();
this.gameOverStage.draw();
}
}
public void update(float deltaTime) {
if (gameOver == false) {
progressBar.setValue(gameTime);
gameTime -= deltaTime;
}
if (gameTime <= 0) {
if (gameOver == false) {
gameOver();
}
}
}
有什么建议吗??
覆盖您的屏幕
/游戏
的resize
方法,并更新您的舞台视图。
@Override
public void resize(int width,int height){
gameOverStage.getViewport().update(width,height);
}
0.2.X
从 0.8.x, 0.9.x, 0.10.0.x, 0.10.1.x, 0.10.2.x, 0.11.0.x 升级到1.0.0 Kafka 1.0.0 介绍了通信协议方面的改变。 遵循下面的滚动升级计划,可以保证您在升级过程中不用停机。 在升级之前,请先查看1.0.0版本中显著的变化。 滚动升级计划: 更新所有代理上的server.properties 并添加以下属性: CURRENT_KAFKA
无非就3个原因吧 为了fix bug 为了新特性 为了爱,就是要追新 从1.a.38开始的版本,升级到最新版的成本都不大. 做到100%兼容是不现实的,但可以肯定的是, 遇到的问题的均有解决的办法. 有些兼容性问题,属于"错误"得到修正,老版本能这样写是"bug", ^_^ 这是一个汇总帖子,随时更新, 也会按版本的增长继续增长.... 请先浏览当前版本到最新版的发行注记,然后再看本列表 IE下a
MinDoc 根据发布系统功能不同可分为两步进行升级。有些用户可能会自定义了模板,覆盖时请注意备份。尤其是要注意备份配置文件和数据库。 版本查看 通过命令行执行如下命令: ./mindoc version 会看到如下的版本信息: #当前安装的版本版本号 MinDoc current version => v1.0 #最新版本版本号 MinDoc last version => v1.0 一、覆
我在Ubuntu18.04上使用ELasticsearch。当我尝试运行“./elasticsearch-setup-passwords”脚本时,它显示以下错误。 未来版本的Elasticsearch将需要Java 11;您的Java版本[/usr/lib/jvm/java-8-openjdk-amd64/jre]不符合此要求 但当我检查Jaa版本时,它显示的是Java 11号。 我把Java从8
我正在尝试在我们现有的多个项目中将spring从2.1.1升级到2.2.0。我已经在几个项目中完成了这项工作,一切都很顺利。 在当前项目中,我做了相同的更改: 现在,当我尝试启动我的应用程序时,我遇到以下错误: 我检查过,根据文档,这个类应该在我当前的spring core版本中可用:https://docs.spring.io/spring/docs/5.2.0.RELEASE/javadoc-