每次渲染函数调用时,我都会将纹理设置为调整为Gdx.graphics.getWidth()
,Gdx.graphics.getHeight()
。事实上,当我启动应用程序时,纹理设置为全屏(我想要)。但是当我改变应用程序的大小时,纹理会以一种愚蠢的方式绘制,而我希望它始终是全屏的。
以下是代码:
package com.leopikinc.bobdestroyer;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
public class BobDestroyer extends ApplicationAdapter {
SpriteBatch batch;
Texture mainscreen;
Music intromusic;
float VOLUME;
@Override
public void create () {
VOLUME = 1f;
batch = new SpriteBatch();
mainscreen = new Texture(Gdx.files.internal("data/FirstLevel.png"));
intromusic = Gdx.audio.newMusic(Gdx.files.internal("data/IntroMusic.mp3"));
intromusic.setLooping(true);
intromusic.setVolume(VOLUME);
intromusic.play();
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 1, 1, 0);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(mainscreen, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
batch.end();
}
@Override
public void resize(int width, int height){
}
}
答案 0 :(得分:0)