DKoding

I am currently using Spine for LibGDX for my game development.
I want to utilize the new 'tint black' functionality for more variation in my enemies.

I use SpriteBatch all over the place today - so the question is: can I simply replace all SpriteBatch calls with the new TwoColorPolygonBatch and I'm good to go? Or do I have to maintain two different sprite batches - one for Spine actors and a different one for everything else?

What are the performance implications if I were to use TwoColorPolygonBatch everywhere?
DKoding
  • 記事: 9

Mario

Yes, both implement the Batch interface so you can use TwoColorPolygonBatch anywhere you use a SpriteBatch. Note that if you manually submit vertex data to draw, you can use the TwoColorPolygonBatch.drawTwoColor() method to avoid a data conversion due to differing vertex formats. Other than that, the only other difference is a slight increase in memory as each vertex will now store an additional 32-bit color, and a slightly more complex fragment shader, neither of which should have any noticable impact on performance on both desktop and mobile.
アバター
Mario

Mario
  • 記事: 2651

DKoding

Thank you for your reply. I have now replaced all my batch calls with the new TwoColorPolygonBatch draw calls. However this results in the following problem when rendering (admittedly large amounts of) text to the screen:

java.lang.ArrayIndexOutOfBoundsException: Index 12000 out of bounds for length 12000
at com.esotericsoftware.spine.utils.TwoColorPolygonBatch.draw(TwoColorPolygonBatch.java:877)

Is the solution to just increase the batch size or do I have to consider something else?
DKoding
  • 記事: 9

Mario

Yes, you have to increase the maximum vertex number of the batch. It's 2000 by default. Use the corresponding constructor. There's a limit of 32k vertices.
アバター
Mario

Mario
  • 記事: 2651


Return to Runtimes