Class SpriteBatch

java.lang.Object
arc.graphics.g2d.Batch
arc.graphics.g2d.SpriteBatch
All Implemented Interfaces:
Disposable
Direct Known Subclasses:
SortedSpriteBatch

public class SpriteBatch extends Batch
  • Field Details

  • Constructor Details

    • SpriteBatch

      public SpriteBatch()
      Constructs a new SpriteBatch with a size of 4096, one buffer, and the default shader.
      See Also:
    • SpriteBatch

      public SpriteBatch(int size)
      Constructs a SpriteBatch with one buffer and the default shader.
      See Also:
    • SpriteBatch

      public SpriteBatch(int size, Shader defaultShader)
      Constructs a new SpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards, x-axis point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect with respect to the current screen resolution.

      The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than the ones expect for shaders set with Batch.setShader(Shader).

      Parameters:
      size - The max number of sprites in a single batch. Max of 8191.
      defaultShader - The default shader to use. This is not owned by the SpriteBatch and must be disposed separately.
  • Method Details

    • flush

      protected void flush()
      Specified by:
      flush in class Batch
    • draw

      protected void draw(Texture texture, float[] spriteVertices, int offset, int count)
      Specified by:
      draw in class Batch
    • draw

      protected void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float rotation)
      Specified by:
      draw in class Batch
    • createShader

      public static Shader createShader()