Libgdx - 最大精灵(Libgdx - maximum sprites)
如果我在屏幕上绘制大约300个精灵,旧的手机是否能以60 fps工作? 只有玩家才能检查碰撞! 对于较旧的手机它可以正常工作吗?
Would the older phones work at 60 fps if I would draw around 300 sprites on screen. Collision would be checked only with the player! Would it work fine for older phones?
最满意答案
实际上,旧设备没有银弹,而且300个圆圈对于绘图来说太多了,但这里有一些提高性能的常用技巧:
使用对象池 不要在渲染循环中经常使用batch.begin()或batch.end() 。 不要绘制或(可能)检查不在视口(屏幕)中的圆圈的碰撞。 不要在渲染循环中创建新纹理/精灵。 使用纹理图集 ,也不需要300个纹理来绘制所有圆圈。 您可以为多个圆圈使用相同的纹理区域。 使用Android监视器分析您的游戏。 看一下android pref提示 不要使用android模拟器来测试你的游戏:) 单个批次中的最大精灵数量为5460 看看sprite批处理的性能调优Actually there is no silver bullet for older devices and also 300 circles are too much for drawing, but here are some common tips for improving performance:
Use Object Pooling Don't use batch.begin() or batch.end() too often in your render loop. Don't draw or (maybe)check collision for those circles that are not in the viewport(screen). Don't create new texture/sprite in your render loop. Use Texture Atlas, also you don't need 300 textures for drawing all circles. You can use a same texture region for multiple circles. Use Android Monitor for profiling your game. Take a look at android pref tips Don't use android emulator for testing your game :) Maximum number of sprites in a single batch is 5460 Take a look at performance tuning for sprite batch更多推荐
发布评论