ShapeRenderer 不在图像后面绘制填充矩形
ShapeRenderer not drawing FilledRectangles behind Images
我正在尝试使用此代码在两个不同的图像后面绘制 FilledRectangles。但是 ShapeRenderer 没有绘制任何东西。
public void render(float delta) {
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(tankColor);
shapeRenderer.rect(tankButton.x, tankButton.y,
tankButton.width+50, tankButton.height+50);
shapeRenderer.setColor(notesColor);
shapeRenderer.rect(notesButton.x, notesButton.y,
notesButton.width+50, notesButton.height+50);
shapeRenderer.end();
batch.begin();
batch.draw(assetsLoader.backTexture, 0, 0, screenWidth, screenHeight);
assetsLoader.shadow.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150 + 5,
200 + assetsLoader.font.getCapHeight() + 5, 400, Align.center, false);
assetsLoader.font.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150,
200 + assetsLoader.font.getCapHeight(), 400, Align.center, false);
// draw tank and notes image
batch.draw(assetsLoader.tankTexture, tankButton.x, tankButton.y,
tankButton.getWidth(), tankButton.getHeight());
batch.draw(assetsLoader.notesTexture, notesButton.x, notesButton.y,
notesButton.getWidth(), notesButton.getHeight());
batch.end();
}
这是我得到的:
这是我需要的:
我明白了。我所要做的就是在插入填充矩形后开始另一批。这就是我所做的:
public void render(float delta) {
batch.begin();
batch.draw(assetsLoader.backTexture, 0, 0, screenWidth, screenHeight);
assetsLoader.shadow.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150 + 5,
200 + assetsLoader.font.getCapHeight() + 5, 400, Align.center, false);
assetsLoader.font.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150,
200 + assetsLoader.font.getCapHeight(), 400, Align.center, false);
batch.end();
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(tankColor);
shapeRenderer.rect(tankButton.x-25, tankButton.y-25,
tankButton.width+50, tankButton.height+50);
shapeRenderer.setColor(notesColor);
shapeRenderer.rect(notesButton.x-25, notesButton.y-25,
notesButton.width+50, notesButton.height+50);
shapeRenderer.end();
batch.begin();
batch.draw(assetsLoader.tankTexture, tankButton.x, tankButton.y,
tankButton.getWidth(), tankButton.getHeight());
batch.draw(assetsLoader.notesTexture, notesButton.x, notesButton.y,
notesButton.getWidth(), notesButton.getHeight());
batch.end();
我正在尝试使用此代码在两个不同的图像后面绘制 FilledRectangles。但是 ShapeRenderer 没有绘制任何东西。
public void render(float delta) {
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(tankColor);
shapeRenderer.rect(tankButton.x, tankButton.y,
tankButton.width+50, tankButton.height+50);
shapeRenderer.setColor(notesColor);
shapeRenderer.rect(notesButton.x, notesButton.y,
notesButton.width+50, notesButton.height+50);
shapeRenderer.end();
batch.begin();
batch.draw(assetsLoader.backTexture, 0, 0, screenWidth, screenHeight);
assetsLoader.shadow.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150 + 5,
200 + assetsLoader.font.getCapHeight() + 5, 400, Align.center, false);
assetsLoader.font.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150,
200 + assetsLoader.font.getCapHeight(), 400, Align.center, false);
// draw tank and notes image
batch.draw(assetsLoader.tankTexture, tankButton.x, tankButton.y,
tankButton.getWidth(), tankButton.getHeight());
batch.draw(assetsLoader.notesTexture, notesButton.x, notesButton.y,
notesButton.getWidth(), notesButton.getHeight());
batch.end();
}
这是我得到的:
这是我需要的:
我明白了。我所要做的就是在插入填充矩形后开始另一批。这就是我所做的:
public void render(float delta) {
batch.begin();
batch.draw(assetsLoader.backTexture, 0, 0, screenWidth, screenHeight);
assetsLoader.shadow.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150 + 5,
200 + assetsLoader.font.getCapHeight() + 5, 400, Align.center, false);
assetsLoader.font.draw(batch, " Touch for Sound !",
Gdx.graphics.getWidth() / 2f - 150,
200 + assetsLoader.font.getCapHeight(), 400, Align.center, false);
batch.end();
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(tankColor);
shapeRenderer.rect(tankButton.x-25, tankButton.y-25,
tankButton.width+50, tankButton.height+50);
shapeRenderer.setColor(notesColor);
shapeRenderer.rect(notesButton.x-25, notesButton.y-25,
notesButton.width+50, notesButton.height+50);
shapeRenderer.end();
batch.begin();
batch.draw(assetsLoader.tankTexture, tankButton.x, tankButton.y,
tankButton.getWidth(), tankButton.getHeight());
batch.draw(assetsLoader.notesTexture, notesButton.x, notesButton.y,
notesButton.getWidth(), notesButton.getHeight());
batch.end();