本文介绍了SpriteBatch全部绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我对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 Cameras frustum or will it draw it, even if it is outside the frustum?

I was allready looking at the SpriteBatchs 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全部绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 12:25