问题描述
是否可以在SpriteBatch
begin
和end
调用之间使用ShapeRenderer
绘制形状.
Is it possible to draw shapes by using ShapeRenderer
between SpriteBatch
begin
and end
calls.
我尝试过但没有结果,只绘制了SpriteBatch纹理,没有任何形状.示例代码如下:
I have tried but no result, only SpriteBatch textures are drawn, no shape is on the scene. Sample code is as followed below :
shapeRenderer.begin(ShapeType.FilledCircle);
shapeRenderer.setColor(0f, 1f, 0f, 1f);
shapeRenderer.filledCircle( 100, 100, 100);
shapeRenderer.end();
我有一个通过以下命令创建的正交摄影机:
I have a orthographic camera created by these commands :
camera = new OrthographicCamera(1, Gdx.graphics.getHeight() / Gdx.graphics.getWidth());
camera.setToOrtho(true);
推荐答案
ShapeRenderer
和SpriteBatch
都在OpenGL中设置了它们希望在使用过程中保持不变的状态.嵌套它们会产生问题.请参阅此帖子在badlogic论坛中.
Both ShapeRenderer
and SpriteBatch
set state in OpenGL that they expect to remain constant during their use. Nesting them can create problems. See this post in the badlogic forum.
应该在文档中更清楚地说明这一点.
This should probably be spelled out a bit more clearly in the docs.
这篇关于在SpriteBatch.begin/end中嵌套ShapeRenderer.begin/end的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!