问题描述
我对Libgdx SpriteBatch
有疑问:
当我调用 SpriteBatch#draw()
时,Libgdx是否会照顾 Camera
的视锥,即使它位于视锥之外,还是会绘制?/p>
我已经准备好查看 SpriteBatch
的代码,但是我什么也没找到,所以我想知道Libgdx是否在内部执行某些操作.还是我必须自己实施frstum淘汰像这样:
if(camera.frustum.boundsInFrustum(250,32,0,100,100,0)){tempEnemy.draw(批处理);}
其中 tempEnemy
是 Sprite
,其中(250,32)是其中心,而(100,100)是其一半大小.
如果我正确理解您的意思,您是在问Libgdxs SpriteBatch
是否关心 ViewFrustum
和只是绘制可见的部分,或者只是绘制您告诉他绘制的所有内容.
如果那是问题,答案是, SpriteBatch
绘制所有内容,而忽略 ViewFrustum
.您必须自己解决这个问题,或者使用Scene2D,它似乎在做一些淘汰.
I have a question regarding the Libgdx SpriteBatch
:
When I call SpriteBatch#draw()
, will Libgdx take care about the Camera
s frustum or will it draw it, even if it is outside the frustum?
I was allready looking at the SpriteBatch
s code, but I did not find anything, so I was wondering, if Libgdx does something internally.Or do I have to implement frstum culling myself e.g. like this:
if(camera.frustum.boundsInFrustum(250, 32, 0, 100, 100 ,0)) {
tempEnemy.draw (batch);
}
Where tempEnemy
is a Sprite
, (250,32) is it's center and (100,100) is his half size.
If i understand you correctly, you are asking, whether Libgdxs SpriteBatch
takes care about the ViewFrustum
and just draws visible parts or if it just draws everything you tell him to draw.
If thats the question, the answer is, the SpriteBatch
draws everything, ignoring the ViewFrustum
. You have to take care about that yourself, or use Scene2D, which seems to do some culling.
这篇关于SpriteBatch全部绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!