我是安卓开发的新手,我正在尝试使用LibGDX创建flappy bird游戏。当我插入管道时,我得到了一些空白空间,如下图所示。我怎么才能修复它?

batch.draw(tTube, tubeX, Gdx.graphics.getHeight() / 2 + gap / 2 + tubeOffset);
batch.draw(bTube, tubeX, Gdx.graphics.getHeight() / 2 - gap / 2 - bTube.getHeight() + tubeOffset);谢谢
发布于 2020-01-02 14:50:23
只是让它更长一点。
如果间隙在最底部,并且您以Gdx.graphics.getHeight()/2或更小的速度绘制顶管height,顶管将无法到达屏幕的顶部。但是,如果您确保管是Gdx.graphics.getHeight()的,那么管将始终到达顶部。
Vector2 tubeSize;
float gapPos;
public void create(){
...
...
tubeSize = Scaling.fillY.apply(tTube.getWidth(),tTube.getHeight(),0, Gdx.graphics.getHeight());
//Make the gap size 20% of the screen height, or edit as you like
gapSize = Gdx.graphics.getHeight() * 0.20f;
// Make a random gap position on the y axis
gapPos = MathUtils.random(gapSize,Gdx.graphics.getHeight()-gapSize);
}
public void render(){
...
...
batch.begin();
batch.draw(tTube, tubeX, gapPos + gapSize/2,tubeSize.x,tubeSize.y);
batch.draw(bTube, tubeX, gapPos - gapSize/2 - tubeSize.y,tubeSize.x,tubeSize.y);
batch.end();
}当然,这会使管看起来更大,但如果编辑png文件并使管更长,则应存档所需的结果。

管子更长的...

https://stackoverflow.com/questions/59550309
复制相似问题