Class SpriteBatch

java.lang.Object
edu.cornell.gdiac.graphics.SpriteBatch
All Implemented Interfaces:
com.badlogic.gdx.graphics.g2d.Batch, com.badlogic.gdx.utils.Disposable

public class SpriteBatch extends Object implements com.badlogic.gdx.graphics.g2d.Batch
This class is a sprite batch for drawing 2d graphics.

A sprite batch gathers together sprites and draws them as a single mesh whenever possible. However this sprite batch is different from a classic sprite batch (from XNA or LibGDX) in that it provides a complete 2d graphics pipeline supporting both solid shapes and outlines, with texture, gradient, and scissor mask support.

This sprite batch is capable of drawing with an active texture. In that case, the shape will be drawn with a solid color. If no color has been specified, the default color is white. Outlines use the same texturing rules that solids do. There is also support for a simple, limited radius blur effect on textures.

Color gradient support is provided by the Gradient class. All gradients will be tinted by the current color (so the color should be reset to white before using a gradient).

Scissor masks are supported by the Scissor class. This is useful for constraining shapes to an internal window. A scissor mask must be a transformed rectangle; it cannot mask with arbitrary polygons.

Drawing only occurs when the methods flush() or end() are called. Because loading vertices into a VertexBuffer is an expensive operation, this sprite batch attempts to minimize this as much as possible. Even texture switches are batched. However, it is still true that using a single texture atlas can significantly improve drawing speed.

A review of this class shows that there are a lot of redundant drawing methods. The scene graphs only use the Mesh methods. This goal has been to make this class more accessible to students familiar with classic sprite batches found in LibGDX or XNA.

It is possible to swap out the shader for this class with another one. Any shader for this class should support SpriteMesh as its vertex data. If you need additional vertex information, such as normals, you should create a new class. It should also have a uniform for the perspective matrix, texture, and drawing type (type 0). Support for gradients and scissors occur via a uniform block that is provides the data in the order scissor, and then gradient. See SpriteShader.frag for more information.

This is an extremely heavy-weight class. There is rarely any need to have more than one of these at a time. If you want to implement your own shader effects, it is better to construct your own custom pipeline with Shader and VertexBuffer.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An enumeration of standard color blending options.
    class 
    Pool of text layout objects.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default vertex capacity

    Fields inherited from interface com.badlogic.gdx.graphics.g2d.Batch

    C1, C2, C3, C4, U1, U2, U3, U4, V1, V2, V3, V4, X1, X2, X3, X4, Y1, Y2, Y3, Y4
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new SpriteBatch with the default capacity and default shader.
    SpriteBatch(int size)
    Constructs a SpriteBatch with the given size and the default shader.
    SpriteBatch(int size, Shader shader)
    Constructs a SpriteBatch with the given capacity and shader.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Starts drawing with the current perspective matrix.
    void
    begin(com.badlogic.gdx.graphics.Camera camera)
    Starts drawing with the given camera.
    void
    clearHalfStencil(boolean lower)
    Clears half of the stencil buffer.
    void
    Clears the stencil buffer.
    static com.badlogic.gdx.math.Affine2
    computeTransform(float ox, float oy, float x, float y, float angle, float sx, float sy)
    Returns the affine transform for the given parameters.
    static com.badlogic.gdx.math.Affine2
    computeTransform(com.badlogic.gdx.math.Affine2 mat, float ox, float oy, float x, float y, float angle, float sx, float sy)
    Sets the affine transform for the given parameters.
    static com.badlogic.gdx.math.Affine2
    computeTransform(com.badlogic.gdx.math.Affine2 mat, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 position, float angle, com.badlogic.gdx.math.Vector2 scale)
    Sets the affine transform for the given parameters.
    static com.badlogic.gdx.math.Affine2
    computeTransform(com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 position, float angle, com.badlogic.gdx.math.Vector2 scale)
    Returns the affine transform for the given parameters.
    void
    Turns off color blending support in this sprite batch
    void
    Deletes the vertex buffers and resets all attributes.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y)
    Draws a rectangle with the bottom left corner at x,y having the width and height of the region.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float width, float height)
    Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
    Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise)
    Draws a rectangle with the texture coordinates by the given amount.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float width, float height, com.badlogic.gdx.math.Affine2 transform)
    Draws a rectangle transformed by the given matrix.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, com.badlogic.gdx.math.Affine2 transform)
    Draws the the texture with the transform.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, Poly2 poly, float x, float y)
    Draws the textured polygon at the given position
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, Poly2 poly, com.badlogic.gdx.math.Affine2 transform)
    Draws the given polygon of the texture with the transform.
    void
    draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, Poly2 poly, com.badlogic.gdx.math.Vector2 offset)
    Draws the textured polygon at the given position
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float[] spriteVertices, int offset, int count)
    Draws a rectangle using the given vertices.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float x, float y)
    Draws a rectangle with the bottom left corner at x,y having the width and height of the texture.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height)
    Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2)
    Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
    Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
    Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)
    Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.math.Affine2 transform)
    Draws the the texture with the transform.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, Poly2 poly, float x, float y)
    Draws the textured polygon at the given position
    void
    draw(com.badlogic.gdx.graphics.Texture texture, Poly2 poly, com.badlogic.gdx.math.Affine2 transform)
    Draws the given polygon of the texture with the transform.
    void
    draw(com.badlogic.gdx.graphics.Texture texture, Poly2 poly, com.badlogic.gdx.math.Vector2 offset)
    Draws the textured polygon at the given position
    void
    drawMesh(SpriteMesh mesh, float x, float y, boolean tint)
    Draws the given mesh with the current texture and/or gradient.
    void
    drawMesh(SpriteMesh mesh, com.badlogic.gdx.math.Affine2 transform, boolean tint)
    Draws the given mesh with the current texture and/or gradient.
    void
    drawMesh(SpriteMesh mesh, com.badlogic.gdx.math.Vector2 offset, boolean tint)
    Draws the given mesh with the current texture and/or gradient.
    void
    Draws the formatted text on the screen.
    void
    drawText(TextLayout layout, float x, float y)
    Draws the formatted text on the screen.
    void
    drawText(TextLayout layout, com.badlogic.gdx.math.Affine2 transform)
    Draws the formatted text on the screen.
    void
    drawText(TextLayout layout, com.badlogic.gdx.math.Vector2 pos)
    Draws the formatted text on the screen.
    void
    drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font)
    Draws the text on the screen.
    void
    drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font, float x, float y)
    Draws the text on the screen.
    void
    drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font, com.badlogic.gdx.math.Affine2 transform)
    Draws the text on the screen.
    void
    drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font, com.badlogic.gdx.math.Vector2 pos)
    Draws the text on the screen.
    void
    Sets this sprite batch to support color blending
    void
    end()
    Completes the drawing pass for this sprite batch, flushing the buffer.
    void
    fill(float x, float y, float width, float height)
    Draws the given rectangle filled with the current color and texture.
    void
    fill(com.badlogic.gdx.math.Rectangle rect)
    Draws the given rectangle filled with the current color and texture.
    void
    fill(com.badlogic.gdx.math.Rectangle rect, float x, float y)
    Draws the given rectangle filled with the current color and texture.
    void
    fill(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Affine2 transform)
    Draws the given rectangle filled with the current color and texture.
    void
    fill(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 offset)
    Draws the given rectangle filled with the current color and texture.
    void
    fill(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
    Draws the given rectangle filled with the current color and texture.
    void
    fill(Poly2 poly)
    Draws the given polygon filled with the current color and texture.
    void
    fill(Poly2 poly, float x, float y)
    Draws the given polygon filled with the current color and texture.
    void
    fill(Poly2 poly, com.badlogic.gdx.math.Affine2 transform)
    Draws the given polygon filled with the current color and texture.
    void
    fill(Poly2 poly, com.badlogic.gdx.math.Vector2 offset)
    Draws the given polygon filled with the current color and texture.
    void
    fill(Poly2 poly, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
    Draws the given polygon filled with the current color and texture.
    void
    Flushes the current mesh without completing the drawing pass.
    int
    Returns the destination blending function for the RGB components
    int
    Returns the destination blending function for the alpha component
    int
    Returns the blending equation for this sprite batch
    int
    Returns the source blending function for the RGB components
    int
    Returns the source blending function for the alpha component
    float
    Returns the blur radius in pixels (0 if there is no blurring).
    com.badlogic.gdx.graphics.Color
    Returns the active color of this sprite batch
    int
    Returns the current drawing command.
    Returns the active gradient of this sprite batch
    float
    Returns the packed representation of the active color
    com.badlogic.gdx.math.Matrix4
    Returns the active perspective matrix of this sprite batch
    Returns the active scissor mask of this sprite batch
    com.badlogic.gdx.graphics.glutils.ShaderProgram
    Returns the shader for this sprite batch
    Returns the current stencil effect
    com.badlogic.gdx.math.Matrix4
    Returns the active transform matrix of this sprite batch
    boolean
    Returns whether this sprite batch supports color blending
    boolean
    Returns true if this sprite batch is actively drawing.
    void
    outline(float x, float y, float width, float height)
    Outlines the given rectangle with the current color and texture.
    void
    outline(com.badlogic.gdx.math.Rectangle rect)
    Outlines the given rectangle with the current color and texture.
    void
    outline(com.badlogic.gdx.math.Rectangle rect, float x, float y)
    Outlines the given rectangle with the current color and texture.
    void
    outline(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Affine2 transform)
    Outlines the given rectangle with the current color and texture.
    void
    outline(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 offset)
    Outlines the given rectangle with the current color and texture.
    void
    outline(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
    Outlines the given rectangle with the current color and texture.
    void
    outline(Path2 path)
    Outlines the given path with the current color and texture.
    void
    outline(Path2 path, float x, float y)
    Outlines the given path with the current color and texture.
    void
    outline(Path2 path, com.badlogic.gdx.math.Affine2 transform)
    Outlines the given path with the current color and texture.
    void
    outline(Path2 path, com.badlogic.gdx.math.Vector2 offset)
    Outlines the given path with the current color and texture.
    void
    outline(Path2 path, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
    Outlines the given path with the current color and texture.
    void
    setBlendDstFunc(int func)
    Sets the blending function for the destination color
    void
    setBlendDstFunc(int rgb, int alpha)
    Sets the blending functions for the destination color
    void
    setBlendEquation(int equation)
    Sets the blending equation for this sprite batch
    void
    setBlendFunction(int srcFactor, int dstFactor)
    Sets the blending function for this sprite batch
    void
    setBlendFunctionSeparate(int srcFactorColor, int dstFactorColor, int srcFactorAlpha, int dstFactorAlpha)
    Sets the blending function for this sprite batch
    void
    Sets the blending mode for this sprite batch
    void
    setBlendSrcFunc(int func)
    Sets the blending function for the source color
    void
    setBlendSrcFunc(int rgb, int alpha)
    Sets the blending functions for the source color
    void
    setBlur(float radius)
    Sets the blur radius in pixels (0 if there is no blurring).
    void
    setColor(float r, float g, float b, float a)
    Sets the active color of this sprite batch
    void
    setColor(com.badlogic.gdx.graphics.Color tint)
    Sets the active color of this sprite batch
    void
    setCommand(int command)
    Sets the current drawing command.
    void
    Sets the active gradient of this sprite batch
    void
    setPackedColor(float packed)
    Sets the active color of this sprite batch
    void
    setProjectionMatrix(com.badlogic.gdx.math.Matrix4 projection)
    Sets the active perspective matrix of this sprite batch
    void
    Sets the active scissor mask of this sprite batch
    void
    setShader(com.badlogic.gdx.graphics.glutils.ShaderProgram shader)
    Sets the shader for this sprite batch
    void
    setShader(Shader shader)
    Sets the shader for this sprite batch
    void
    Sets the current stencil effect
    void
    setTexture(com.badlogic.gdx.graphics.Texture texture)
    Sets the active texture of this sprite batch
    void
    setTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion region)
    Sets the active texture region of this sprite batch
    void
    setTransformMatrix(com.badlogic.gdx.math.Matrix4 transform)
    Sets the active transform matrix of this sprite batch

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CAPACITY

      public static final int DEFAULT_CAPACITY
      The default vertex capacity
      See Also:
  • Constructor Details

    • SpriteBatch

      public SpriteBatch()
      Constructs a new SpriteBatch with the default capacity and default shader.
      See Also:
    • SpriteBatch

      public SpriteBatch(int size)
      Constructs a SpriteBatch with the given size and the default shader.
      Parameters:
      size - The vertex capacity
      See Also:
    • SpriteBatch

      public SpriteBatch(int size, Shader shader)
      Constructs a SpriteBatch with the given capacity and shader.

      The shader is not owned by this sprite batch and must be disposed of separately. If extended is false, the shader it assumed to be a traditional sprite shader with a stride of 5 floats (position, color, and texture coords). If extended it true, it has a stride of 7 in order to include gradient coordinates.

      Parameters:
      size - The vertex capacity
      shader - The shader to use
  • Method Details

    • dispose

      public void dispose()
      Deletes the vertex buffers and resets all attributes.

      Unlike CUGL, a disposed LibGDX object is not designed to be reused. This is designed to get rid of the heavy-weight OpenGL classes.

      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • isDrawing

      public boolean isDrawing()
      Returns true if this sprite batch is actively drawing.

      Some changes cannot be made while the sprite batch is drawing.

      Specified by:
      isDrawing in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      true if this sprite batch is actively drawing.
    • setShader

      public void setShader(Shader shader)
      Sets the shader for this sprite batch

      This value may NOT be changed during a drawing pass. The shader must be attribute compatible with the original shader.

      Parameters:
      shader - The active shader for this sprite batch
    • setShader

      public void setShader(com.badlogic.gdx.graphics.glutils.ShaderProgram shader)
      Sets the shader for this sprite batch

      This value may NOT be changed during a drawing pass.

      Specified by:
      setShader in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      shader - The active shader for this sprite batch
    • getShader

      public com.badlogic.gdx.graphics.glutils.ShaderProgram getShader()
      Returns the shader for this sprite batch

      This value may NOT be changed during a drawing pass.

      Specified by:
      getShader in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the shader for this sprite batch
    • setColor

      public void setColor(com.badlogic.gdx.graphics.Color tint)
      Sets the active color of this sprite batch

      All subsequent shapes and outlines drawn by this sprite batch will be tinted by this color. This color is white by default.

      Specified by:
      setColor in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      tint - The active color for this sprite batch
    • setColor

      public void setColor(float r, float g, float b, float a)
      Sets the active color of this sprite batch

      All subsequent shapes and outlines drawn by this sprite batch will be tinted by this color. This color is white by default.

      Specified by:
      setColor in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      r - The red value of the active color
      g - The green value of the active color
      b - The blue value of the active color
      a - The alpha value of the active color
    • getColor

      public com.badlogic.gdx.graphics.Color getColor()
      Returns the active color of this sprite batch

      All subsequent shapes and outlines drawn by this sprite batch will be tinted by this color. This color is white by default.

      Specified by:
      getColor in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the active color for this sprite batch
    • setPackedColor

      public void setPackedColor(float packed)
      Sets the active color of this sprite batch

      All subsequent shapes and outlines drawn by this sprite batch will be tinted by this color. This color is white by default.

      Specified by:
      setPackedColor in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      packed - The packed encoding of the active color
    • getPackedColor

      public float getPackedColor()
      Returns the packed representation of the active color

      This packed representation allows us to represent the color as a single float value.

      Specified by:
      getPackedColor in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the packed representation of the active color
    • isBlendingEnabled

      public boolean isBlendingEnabled()
      Returns whether this sprite batch supports color blending
      Specified by:
      isBlendingEnabled in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      whether this sprite batch supports color blending
    • enableBlending

      public void enableBlending()
      Sets this sprite batch to support color blending
      Specified by:
      enableBlending in interface com.badlogic.gdx.graphics.g2d.Batch
    • disableBlending

      public void disableBlending()
      Turns off color blending support in this sprite batch
      Specified by:
      disableBlending in interface com.badlogic.gdx.graphics.g2d.Batch
    • setBlendMode

      public void setBlendMode(SpriteBatch.BlendMode mode)
      Sets the blending mode for this sprite batch

      This method uses our SpriteBatch.BlendMode enum to set one of the predefined blending modes. Most of the time, this should be all that you need.

      Parameters:
      mode - The color blending mode
    • setBlendFunction

      public void setBlendFunction(int srcFactor, int dstFactor)
      Sets the blending function for this sprite batch

      The enums are the standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      However, this setter does not do any error checking to verify that the enums are valid. By default, srcFactor is GL_SRC_ALPHA while dstFactor is GL_ONE_MINUS_SRC_ALPHA. This corresponds to non-premultiplied alpha blending.
      Specified by:
      setBlendFunction in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      srcFactor - Specifies how the source color is blended
      dstFactor - Specifies how the destination color is blended
    • setBlendFunctionSeparate

      public void setBlendFunctionSeparate(int srcFactorColor, int dstFactorColor, int srcFactorAlpha, int dstFactorAlpha)
      Sets the blending function for this sprite batch

      The enums are the standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      However, this setter does not do any error checking to verify that the enums are valid. By default, srcFactor is GL_SRC_ALPHA while dstFactor is GL_ONE_MINUS_SRC_ALPHA. This corresponds to non-premultiplied alpha blending.

      This method is different from setBlendFunction(int,int) in that it allows for separate blend functions for the color and alpha components.

      Specified by:
      setBlendFunctionSeparate in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      srcFactorColor - Specifies how the source color is blended
      dstFactorColor - Specifies how the destination color is blended
      srcFactorAlpha - Specifies how the source alpha is blended
      dstFactorAlpha - Specifies how the destination alpha is blended
    • setBlendSrcFunc

      public void setBlendSrcFunc(int func)
      Sets the blending function for the source color

      The enums are the standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      However, this setter does not do any error checking to verify that the enums are valid.

      By default this value is GL_SRC_ALPHA, as sprite batches do not use premultiplied alpha.

      Parameters:
      func - Specifies how the source color is blended
    • setBlendSrcFunc

      public void setBlendSrcFunc(int rgb, int alpha)
      Sets the blending functions for the source color

      The enums are the standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      This version of the function allows you to specify different blending fuctions for the RGB and alpha components of the source color. This setter does not do any error checking to verify that the enums are valid.

      By default both values are GL_SRC_ALPHA, as sprite batches do not use premultiplied alpha.

      Parameters:
      rgb - The blend function for the source RGB components
      alpha - The blend function for the source alpha component
    • getBlendSrcFunc

      public int getBlendSrcFunc()
      Returns the source blending function for the RGB components

      By default this value is GL_SRC_ALPHA, as sprite batches do not use premultiplied alpha. For other options, see

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      Specified by:
      getBlendSrcFunc in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the source blending function for the RGB components
    • getBlendSrcFuncAlpha

      public int getBlendSrcFuncAlpha()
      Returns the source blending function for the alpha component

      By default this value is GL_SRC_ALPHA, as sprite batches do not use premultiplied alpha. For other options, see

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      Specified by:
      getBlendSrcFuncAlpha in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the source blending function for the alpha component
    • setBlendDstFunc

      public void setBlendDstFunc(int func)
      Sets the blending function for the destination color

      The enums are the standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      However, this setter does not do any error checking to verify that the enums are valid.

      By default this value is GL_ONE_MINUS_SRC_ALPHA, as sprite batches do not use premultiplied alpha.

      Parameters:
      func - Specifies how the source color is blended
    • setBlendDstFunc

      public void setBlendDstFunc(int rgb, int alpha)
      Sets the blending functions for the destination color

      The enums are the standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      This version of the function allows you to specify different blending fuctions for the RGB and alpha components of the destiniation color. This setter does not do any error checking to verify that the enums are valid.

      By default both values are GL_ONE_MINUS_SRC_ALPHA, as sprite batches do not use premultiplied alpha.

      Parameters:
      rgb - The blend function for the source RGB components
      alpha - The blend function for the source alpha component
    • getBlendDstFunc

      public int getBlendDstFunc()
      Returns the destination blending function for the RGB components

      By default this value is GL_ONE_MINUS_SRC_ALPHA, as sprite batches do not use premultiplied alpha. For other options, see

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      Specified by:
      getBlendDstFunc in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the destination blending function for the RGB components
    • getBlendDstFuncAlpha

      public int getBlendDstFuncAlpha()
      Returns the destination blending function for the alpha component

      By default this value is GL_ONE_MINUS_SRC_ALPHA, as sprite batches do not use premultiplied alpha. For other options, see

      https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
      Specified by:
      getBlendDstFuncAlpha in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the destination blending function for the alpha component
    • setBlendEquation

      public void setBlendEquation(int equation)
      Sets the blending equation for this sprite batch

      The enum must be a standard ones supported by OpenGL. See

      https://www.opengl.org/sdk/docs/man/html/glBlendEquation.xhtml
      However, this setter does not do any error checking to verify that the input is valid. By default, the equation is GL_FUNC_ADD.
      Parameters:
      equation - Specifies how source and destination colors are combined
    • getBlendEquation

      public int getBlendEquation()
      Returns the blending equation for this sprite batch

      By default this value is GL_FUNC_ADD. For other options, see

      https://www.opengl.org/sdk/docs/man/html/glBlendEquation.xhtml
      Returns:
      the blending equation for this sprite batch
    • setBlur

      public void setBlur(float radius)
      Sets the blur radius in pixels (0 if there is no blurring).

      This sprite batch supports a simple Gaussian blur. The blur samples at 5 points along each axis. The values are essentially at the radius, half-radius, and center. Because of the limited sampling, large radii will start to produce a pixellation effect. But it can produce acceptable blur effects with little cost to performance. It is especially ideal for font-blur effects on font atlases.

      When applying a blur to a text, make sure that the source font has padding set to at least the blur radius. Otherwise, the blur will bleed into other glyphs.

      Setting this value to 0 will disable texture blurring. This value is 0 by default.

      Parameters:
      radius - The blur radius in pixels
    • getBlur

      public float getBlur()
      Returns the blur radius in pixels (0 if there is no blurring).

      This sprite batch supports a simple Gaussian blur. The blur samples at 5 points along each axis. The values are essentially at the radius, half-radius, and center. Because of the limited sampling, large radii will start to produce a pixellation effect. But it can produce acceptable blur effects with little cost to performance. It is especially ideal for font-blur effects on font atlases.

      When applying a blur to a text, make sure that the source font has padding set to at least the blur radius. Otherwise, the blur will bleed into other glyphs.

      Setting this value to 0 will disable texture blurring. This value is 0 by default.

      Returns:
      the blur step in pixels (0 if there is no blurring).
    • getProjectionMatrix

      public com.badlogic.gdx.math.Matrix4 getProjectionMatrix()
      Returns the active perspective matrix of this sprite batch

      The perspective matrix is the combined modelview-projection from the camera. By default, this is the identity matrix.

      This method returns a copy of the matrix. Changes to this object have no effect on the sprite batch.

      Specified by:
      getProjectionMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the active perspective matrix of this sprite batch
    • getTransformMatrix

      public com.badlogic.gdx.math.Matrix4 getTransformMatrix()
      Returns the active transform matrix of this sprite batch

      The transform matrix is a unified transform applied to all vertices in the sprite batch. By default, this is the identity matrix.

      This method returns a copy of the matrix. Changes to this object have no effect on the sprite batch.

      Specified by:
      getTransformMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      Returns:
      the active perspective matrix of this sprite batch
    • setProjectionMatrix

      public void setProjectionMatrix(com.badlogic.gdx.math.Matrix4 projection)
      Sets the active perspective matrix of this sprite batch

      The perspective matrix is the combined modelview-projection from the camera. By default, this is the identity matrix.

      This method acquires a copy of the matrix. Changes to the original matrix after calling this method have no effect.

      Specified by:
      setProjectionMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      projection - The active projection matrix for this sprite batch
    • setTransformMatrix

      public void setTransformMatrix(com.badlogic.gdx.math.Matrix4 transform)
      Sets the active transform matrix of this sprite batch

      The transform matrix is a unified transform applied to all vertices in the sprite batch. By default, this is the identity matrix.

      This method acquires a copy of the matrix. Changes to the original matrix after calling this method have no effect.

      Specified by:
      setTransformMatrix in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      transform - the active transform matrix of this sprite batch
    • getGradient

      public Gradient getGradient()
      Returns the active gradient of this sprite batch

      Gradients may be used in the place of (and together with) colors.

      By default, the gradient will not be used (as it is slower than solid colors).

      All gradients are tinted by the active color. Unless you explicitly want this tinting, you should set the active color to white before drawing with an active gradient.

      This method returns a copy of the internal gradient. Changes to this object have no effect on the sprite batch.

      Returns:
      The active gradient for this sprite batch
    • setGradient

      public void setGradient(Gradient gradient)
      Sets the active gradient of this sprite batch

      Gradients may be used in the place of (and together with) colors.

      If this value is null, then no gradient is active. In that case, the color vertex attribute will be interpretted as normal (e.g. a traditional color vector). This value is null by default.

      All gradients are tinted by the active color. Unless you explicitly want this tinting, you should set the active color to white before drawing with an active gradient.

      This method acquires a copy of the gradient. Changes to the original gradient after calling this method have no effect.

      Parameters:
      gradient - The active gradient for this sprite batch
    • getScissor

      public Scissor getScissor()
      Returns the active scissor mask of this sprite batch

      Scissor masks may be combined with all types of drawing (colors, textures, and gradients).

      If this value is null, then no scissor mask is active. This value is null by default.

      This method returns a copy of the internal scissor. Changes to this object have no effect on the sprite batch.

      Returns:
      The active scissor mask for this sprite batch
    • setScissor

      public void setScissor(Scissor scissor)
      Sets the active scissor mask of this sprite batch

      Scissor masks may be combined with all types of drawing (colors, textures, and gradients).

      If this value is null, then no scissor mask is active. This value is null by default.

      This method acquires a copy of the scissor. Changes to the original scissor mask after calling this method have no effect.

      Parameters:
      scissor - The active scissor mask for this sprite batch
    • setCommand

      public void setCommand(int command)
      Sets the current drawing command.

      The value must be one of GL_TRIANGLES or GL_LINES. Changing this value during a drawing pass will flush the buffer.

      Parameters:
      command - The OpenGL drawing command
    • getCommand

      public int getCommand()
      Returns the current drawing command.

      The value must be one of GL_TRIANGLES or GL_LINES. Changing this value during a drawing pass will flush the buffer.

      Returns:
      the current drawing command.
    • setTexture

      public void setTexture(com.badlogic.gdx.graphics.Texture texture)
      Sets the active texture of this sprite batch

      All subsequent shapes and outlines drawn by this sprite batch will use this texture. If the value is null, all shapes and outlines will be draw with a solid color instead. This value is null by default.

      Changing this value will cause the sprite batch to flush. This is an important argument for using texture atlases.

      Parameters:
      texture - The active texture for this sprite batch
    • setTextureRegion

      public void setTextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion region)
      Sets the active texture region of this sprite batch

      All subsequent shapes and outlines drawn by this sprite batch will use this texture region. If the value is null, all shapes and outlines will be draw with a solid color instead. This value is null by default.

      Changing the texture will cause the sprite batch to flush. However, using a different region for the same texture will not cause a pipeline flush. This is an important argument for using texture atlases.

      Parameters:
      region - The active texture region for this sprite batch
    • setStencilEffect

      public void setStencilEffect(Stencil.Effect effect)
      Sets the current stencil effect

      Stencil effects can be used to restrict the drawing region and are generally used to speed up the processing of non-convex shapes. See Stencil for the list of supported effects, as well as a discussion of how the two halves of the stencil buffer work.

      This value should be set to Stencil.Effect.NATIVE (the default) if you wish to directly manipulate the OpenGL stencil. This is sometimes necessary for more complex effects.

      Parameters:
      effect - The current stencil effect
    • getStencilEffect

      public Stencil.Effect getStencilEffect()
      Returns the current stencil effect

      Stencil effects can be used to restrict the drawing region and are generally used to speed up the processing of non-convex shapes. See Stencil for the list of supported effects, as well as a discussion of how the two halves of the stencil buffer work.

      This value should be set to Stencil.Effect.NATIVE (the default) if you wish to directly manipulate the OpenGL stencil. This is sometimes necessary for more complex effects.

      Returns:
      the current stencil effect
    • clearStencil

      public void clearStencil()
      Clears the stencil buffer.

      This method clears both halves of the stencil buffer: both upper and lower. See Stencil for a discussion of how the two halves of the stencil buffer work.

    • clearHalfStencil

      public void clearHalfStencil(boolean lower)
      Clears half of the stencil buffer.

      This method clears only one of the two halves of the stencil buffer. See Stencil for a discussion of how the two halves of the stencil buffer work.

      Parameters:
      lower - Whether to clear the lower stencil buffer
    • computeTransform

      public static com.badlogic.gdx.math.Affine2 computeTransform(com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 position, float angle, com.badlogic.gdx.math.Vector2 scale)
      Returns the affine transform for the given parameters.

      One of the reasons for the proliferation of methods in the LibGDX Batch class is all of the ways that we can transform the image. To simplify this, most of our new methods simply use an Affine2 transform. However, computing transforms can be tricky. This method provides an easy way to generate them.

      Parameters:
      origin - The of texture origin (in pixels)
      position - The texture position
      angle - The rotation angle (in degrees) about the origin.
      scale - The scaling factor
      Returns:
      the affine transform for the given parameters.
    • computeTransform

      public static com.badlogic.gdx.math.Affine2 computeTransform(com.badlogic.gdx.math.Affine2 mat, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 position, float angle, com.badlogic.gdx.math.Vector2 scale)
      Sets the affine transform for the given parameters.

      One of the reasons for the proliferation of methods in the LibGDX Batch class is all of the ways that we can transform the image. To simplify this, most of our new methods simply use an Affine2 transform. However, computing transforms can be tricky. This method provides an easy way to generate them.

      Parameters:
      mat - The object to store the results
      origin - The of texture origin (in pixels)
      position - The texture position
      angle - The rotation angle (in degrees) about the origin.
      scale - The scaling factor
      Returns:
      the provided affine transform
    • computeTransform

      public static com.badlogic.gdx.math.Affine2 computeTransform(float ox, float oy, float x, float y, float angle, float sx, float sy)
      Returns the affine transform for the given parameters.

      One of the reasons for the proliferation of methods in the LibGDX Batch class is all of the ways that we can transform the image. To simplify this, most of our new methods simply use an Affine2 transform. However, computing transforms can be tricky. This method provides an easy way to generate them.

      Parameters:
      ox - The x-coordinate of texture origin (in pixels)
      oy - The y-coordinate of texture origin (in pixels)
      x - The x-coordinate of the texture
      y - The y-coordinate of the texture
      angle - The rotation angle (in degrees) about the origin.
      sx - The x-axis scaling factor
      sy - The y-axis scaling factor
      Returns:
      the affine transform for the given parameters.
    • computeTransform

      public static com.badlogic.gdx.math.Affine2 computeTransform(com.badlogic.gdx.math.Affine2 mat, float ox, float oy, float x, float y, float angle, float sx, float sy)
      Sets the affine transform for the given parameters.

      One of the reasons for the proliferation of methods in the LibGDX Batch class is all of the ways that we can transform the image. To simplify this, most of our new methods simply use an Affine2 transform. However, computing transforms can be tricky. This method provides an easy way to generate them.

      Parameters:
      mat - The object to store the results
      ox - The x-coordinate of texture origin (in pixels)
      oy - The y-coordinate of texture origin (in pixels)
      x - The x-coordinate of the texture
      y - The y-coordinate of the texture
      angle - The rotation angle (in degrees) about the origin.
      sx - The x-axis scaling factor
      sy - The y-axis scaling factor
      Returns:
      the provided affine transform
    • begin

      public void begin()
      Starts drawing with the current perspective matrix.

      This call will disable depth buffer writing. It enables blending and texturing. You must call end() to complete drawing.

      Calling this method will reset the vertex and OpenGL call counters to 0.

      Specified by:
      begin in interface com.badlogic.gdx.graphics.g2d.Batch
    • begin

      public void begin(com.badlogic.gdx.graphics.Camera camera)
      Starts drawing with the given camera.

      The camera will be used to set the perspective matrix. This call will disable depth buffer writing. It enables blending and texturing. You must call end() to complete drawing.

      Calling this method will reset the vertex and OpenGL call counters to 0.

      Parameters:
      camera - The camera for the drawing perspective
    • end

      public void end()
      Completes the drawing pass for this sprite batch, flushing the buffer.

      This method will unbind the associated shader. It must always be called after a call to begin().

      Specified by:
      end in interface com.badlogic.gdx.graphics.g2d.Batch
    • flush

      public void flush()
      Flushes the current mesh without completing the drawing pass.

      This method is called whenever you change any attribute other than color mid-pass. It prevents the attribute change from retoactively affecting previuosly drawn shapes.

      If you play to apply any OpenGL functionality not directly supported by this sprite batch (e.g stencils), you MUST call this method first before applying your effects. In addition, you should call this again before restoring the OpenGL state.

      Specified by:
      flush in interface com.badlogic.gdx.graphics.g2d.Batch
    • fill

      public void fill(com.badlogic.gdx.math.Rectangle rect)
      Draws the given rectangle filled with the current color and texture.

      The texture will fill the entire rectangle with texture coordinate (0,1) at the bottom left corner identified by rect,origin. To draw only part of a texture, use a subtexture to fill the rectangle with the region [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to draw
    • fill

      public void fill(float x, float y, float width, float height)
      Draws the given rectangle filled with the current color and texture.

      The texture will fill the entire rectangle with texture coordinate (0,1) at the bottom left corner identified by rect,origin. To draw only part of a texture, use a subtexture to fill the rectangle with the region [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      x - The x-coordinate of the lower left corner
      y - The y-coordinate of the lower left corner
      width - The width of the rectangle
      height - The height of the rectangle
    • fill

      public void fill(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 offset)
      Draws the given rectangle filled with the current color and texture.

      The texture will fill the entire rectangle with texture coordinate (0,1) at the bottom left corner identified by rect,origin. To draw only part of a texture, use a subtexture to fill the rectangle with the region [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to draw
      offset - The rectangle offset
    • fill

      public void fill(com.badlogic.gdx.math.Rectangle rect, float x, float y)
      Draws the given rectangle filled with the current color and texture.

      The texture will fill the entire rectangle with texture coordinate (0,1) at the bottom left corner identified by rect,origin. To draw only part of a texture, use a subtexture to fill the rectangle with the region [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to draw
      x - The rectangle x offset
      y - The rectangle y offset
    • fill

      public void fill(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
      Draws the given rectangle filled with the current color and texture.

      The rectangle will be scaled first, then rotated, and finally offset by the given position. Rotation is measured in radians and is counter clockwise from the x-axis. Rotation will be about the provided origin, which is specified relative to the origin of the rectangle (not world coordinates). So to spin about the center, the origin should be width/2, height/2 of the rectangle.

      The texture will fill the entire rectangle before being transformed. Texture coordinate (0,1) will at the bottom left corner identified by rect,origin. To draw only part of a texture, use a subtexture to fill the rectangle with the region [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to draw
      origin - The rotational offset in the rectangle
      scale - The amount to scale the rectangle
      angle - The amount to rotate the rectangle
      offset - The rectangle offset in world coordinates
    • fill

      public void fill(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Affine2 transform)
      Draws the given rectangle filled with the current color and texture.

      The rectangle will transformed by the given matrix. The transform will be applied to the origin of the rectangle.

      The texture will fill the entire rectangle with texture coordinate (0,1) at the bottom left corner identified by rect,origin. To draw only part of a texture, use a subtexture to fill the rectangle with the region [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to draw
      transform - The coordinate transform
    • fill

      public void fill(Poly2 poly)
      Draws the given polygon filled with the current color and texture.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      poly - The polygon to draw
    • fill

      public void fill(Poly2 poly, com.badlogic.gdx.math.Vector2 offset)
      Draws the given polygon filled with the current color and texture.

      The polygon will be offset by the given position.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      poly - The polygon to draw
      offset - The polygon offset
    • fill

      public void fill(Poly2 poly, float x, float y)
      Draws the given polygon filled with the current color and texture.

      The polygon will be offset by the given position.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this. If depth testing is on, all vertices will use the current sprite batch depth.

      Parameters:
      poly - The polygon to draw
      x - The x offset
      y - The y offset
    • fill

      public void fill(Poly2 poly, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
      Draws the given polygon filled with the current color and texture.

      The polygon will be scaled first, then rotated, and finally offset by the given position. Rotation is measured in radians and is counter clockwise from the x-axis. Rotation will be about the provided origin, which is specified relative to the origin of the polygon (not world coordinates). Hence this origin is essentially the pixel coordinate of the texture (see below) to assign as the rotational center.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      poly - The polygon to draw
      origin - The image origin in pixel space
      scale - The amount to scale the polygon
      angle - The amount to rotate the polygon
      offset - The polygon offset in world coordinates
    • fill

      public void fill(Poly2 poly, com.badlogic.gdx.math.Affine2 transform)
      Draws the given polygon filled with the current color and texture.

      The polygon will transformed by the given matrix. The transform will be applied to the origin of the path (not world coordinates). Hence this origin is essentially the pixel coordinate of the texture (see below) to assign as the origin of this transform.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      poly - The polygon to draw
      transform - The coordinate transform
    • outline

      public void outline(com.badlogic.gdx.math.Rectangle rect)
      Outlines the given rectangle with the current color and texture.

      The drawing will be a wireframe of a rectangle. The wireframe will be textured with Texture coordinate (0,1) at the bottom left corner identified by rect,origin. The remaining edges will correspond to the edges of the texture. To draw only part of a texture, use a subtexture to outline the edges with [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to outline
    • outline

      public void outline(float x, float y, float width, float height)
      Outlines the given rectangle with the current color and texture.

      The drawing will be a wireframe of a rectangle. The wireframe will be textured with Texture coordinate (0,1) at the bottom left corner identified by rect,origin. The remaining edges will correspond to the edges of the texture. To draw only part of a texture, use a subtexture to outline the edges with [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control. If depth testing is on, all vertices will use the current sprite batch depth.

      Parameters:
      x - x-coordinate
      y - y-coordinate
      width - width of outline box
      height - height of outline box
    • outline

      public void outline(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 offset)
      Outlines the given rectangle with the current color and texture.

      The drawing will be a wireframe of a rectangle. The wireframe will be textured with Texture coordinate (0,1) at the bottom left corner identified by rect,origin. The remaining edges will correspond to the edges of the texture. To draw only part of a texture, use a subtexture to outline the edges with [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to outline
      offset - The rectangle offset
    • outline

      public void outline(com.badlogic.gdx.math.Rectangle rect, float x, float y)
      Outlines the given rectangle with the current color and texture.

      The drawing will be a wireframe of a rectangle. The wireframe will be textured with Texture coordinate (0,1) at the bottom left corner identified by rect,origin. The remaining edges will correspond to the edges of the texture. To draw only part of a texture, use a subtexture to outline the edges with [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to outline
      x - The rectangle x offset
      y - The rectangle y offset
    • outline

      public void outline(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
      Outlines the given rectangle with the current color and texture.

      The rectangle will be scaled first, then rotated, and finally offset by the given position. Rotation is measured in radians and is counter clockwise from the x-axis. Rotation will be about the provided origin, which is specified relative to the origin of the rectangle (not world coordinates). So to spin about the center, the origin should be width/2, height/2 of the rectangle.

      The drawing will be a wireframe of a rectangle. The wireframe will be textured with Texture coordinate (0,1) at the bottom left corner identified by rect,origin. The remaining edges will correspond to the edges of the texture. To draw only part of a texture, use a subtexture to outline the edges with [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to outline
      origin - The rotational offset in the rectangle
      scale - The amount to scale the rectangle
      angle - The amount to rotate the rectangle
      offset - The rectangle offset in world coordinates
    • outline

      public void outline(com.badlogic.gdx.math.Rectangle rect, com.badlogic.gdx.math.Affine2 transform)
      Outlines the given rectangle with the current color and texture.

      The rectangle will transformed by the given matrix. The transform will be applied to the origin of the rectangle (not world coordinates).

      The drawing will be a wireframe of a rectangle. The wireframe will be textured with Texture coordinate (0,1) at the bottom left corner identified by rect,origin. The remaining edges will correspond to the edges of the texture. To draw only part of a texture, use a subtexture to outline the edges with [minS,maxS]x[min,maxT]. Alternatively, you can use a Poly2 for more fine-tuned control.

      Parameters:
      rect - The rectangle to outline
      transform - The coordinate transform
    • outline

      public void outline(Path2 path)
      Outlines the given path with the current color and texture.

      The drawing will be a wireframe of a path, but the lines are textured. The vertex coordinates will be determined by path vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply outlining the rectangle.

      One way to think of the path is as a "cookie cutter". Treat the path coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the path. This may make the path larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      path - The path to outline
    • outline

      public void outline(Path2 path, com.badlogic.gdx.math.Vector2 offset)
      Outlines the given path with the current color and texture.

      The path will be offset by the given position.

      The drawing will be a wireframe of a path, but the lines are textured. The vertex coordinates will be determined by path vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply outlining the rectangle.

      One way to think of the path is as a "cookie cutter". Treat the path coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the path. This may make the path larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      path - The path to outline
      offset - The path offset
    • outline

      public void outline(Path2 path, float x, float y)
      Outlines the given path with the current color and texture.

      The path will be offset by the given position.

      The drawing will be a wireframe of a path, but the lines are textured. The vertex coordinates will be determined by path vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply outlining the rectangle.

      One way to think of the path is as a "cookie cutter". Treat the path coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the path. This may make the path larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      path - The path to outline
      x - The x offset
      y - The y offset
    • outline

      public void outline(Path2 path, com.badlogic.gdx.math.Vector2 origin, com.badlogic.gdx.math.Vector2 scale, float angle, com.badlogic.gdx.math.Vector2 offset)
      Outlines the given path with the current color and texture.

      The path will be scaled first, then rotated, and finally offset by the given position. Rotation is measured in radians and is counter clockwise from the x-axis. Rotation will be about the provided origin, which is specified relative to the origin of the path (not world coordinates). Hence this origin is essentially the pixel coordinate of the texture (see below) to assign as the rotational center.

      The drawing will be a wireframe of a path, but the lines are textured. The vertex coordinates will be determined by path vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply outlining the rectangle.

      One way to think of the path is as a "cookie cutter". Treat the path coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the path. This may make the path larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      path - The path to outline
      origin - The image origin in pixel space
      scale - The amount to scale the path
      angle - The amount to rotate the path
      offset - The path offset in world coordinates
    • outline

      public void outline(Path2 path, com.badlogic.gdx.math.Affine2 transform)
      Outlines the given path with the current color and texture.

      The path will transformed by the given matrix. The transform will be applied to the origin of the path (not world coordinates). Hence this origin is essentially the pixel coordinate of the texture (see below) to assign as the origin of this transform.

      The drawing will be a wireframe of a path, but the lines are textured. The vertex coordinates will be determined by path vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply outlining the rectangle.

      One way to think of the path is as a "cookie cutter". Treat the path coordinates as pixel coordinates in the texture file, and use that to determine how the texture fills the path. This may make the path larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      path - The path to outline
      transform - The transform to be applied
    • drawMesh

      public void drawMesh(SpriteMesh mesh, com.badlogic.gdx.math.Vector2 offset, boolean tint)
      Draws the given mesh with the current texture and/or gradient.

      This method provides more fine tuned control over texture coordinates that the other fill/outline methods. The texture no longer needs to be drawn uniformly over the shape. The offset will be applied to the vertex positions directly in world space.

      The drawing command will be determined by the mesh, and the triangulation or lines determined by the mesh indices. The mesh vertices use their own color values. However, if tint is true, these values will be tinted (i.e. multiplied) by the current active color.

      Parameters:
      mesh - The sprite mesh
      offset - The coordinate offset for the mesh
      tint - Whether to tint with the active color
    • drawMesh

      public void drawMesh(SpriteMesh mesh, float x, float y, boolean tint)
      Draws the given mesh with the current texture and/or gradient.

      This method provides more fine tuned control over texture coordinates that the other fill/outline methods. The texture no longer needs to be drawn uniformly over the shape. The offset will be applied to the vertex positions directly in world space.

      The drawing command will be determined by the mesh, and the triangulation or lines determined by the mesh indices. The mesh vertices use their own color values. However, if tint is true, these values will be tinted (i.e. multiplied) by the current active color.

      Parameters:
      mesh - The sprite mesh
      x - The x-coordinate offset for the mesh
      y - The y-coordinate offset for the mesh
      tint - Whether to tint with the active color
    • drawMesh

      public void drawMesh(SpriteMesh mesh, com.badlogic.gdx.math.Affine2 transform, boolean tint)
      Draws the given mesh with the current texture and/or gradient.

      This method provides more fine tuned control over texture coordinates that the other fill/outline methods. The texture no longer needs to be drawn uniformly over the shape. The transform will be applied to the vertex positions directly in world space.

      The drawing command will be determined by the mesh, and the triangulation or lines determined by the mesh indices. The mesh vertices use their own color values. However, if tint is true, these values will be tinted (i.e. multiplied) by the current active color.

      Parameters:
      mesh - The sprite mesh
      transform - The coordinate transform
      tint - Whether to tint with the active color
    • drawText

      public void drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font)
      Draws the text on the screen.

      The text will be left-aligned with the origin at the baseline (e.g. the alignment is TextAlign.baselineLeft.

      This method will draw the font with the current sprite batch color. However, calling this method will erase the current texture.

      Parameters:
      text - The string to draw
      font - The font to use
    • drawText

      public void drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font, float x, float y)
      Draws the text on the screen.

      The text will be left-aligned with the origin at the baseline (e.g. the alignment is TextAlign.baselineLeft. The origin will be offset by the given amount.

      This method will draw the font with the current sprite batch color. However, calling this method will erase the current texture.

      Parameters:
      text - The string to draw
      font - The font to use
      x - The x-coordinate of the lower-left corner
      y - The y-coordinate of the lower-left corner
    • drawText

      public void drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font, com.badlogic.gdx.math.Vector2 pos)
      Draws the text on the screen.

      The text will be left-aligned with the origin at the baseline (e.g. the alignment is TextAlign.baselineLeft. The origin will be offset by the given amount.

      This method will draw the font with the current sprite batch color. However, calling this method will erase the current texture.

      Parameters:
      text - The string to draw
      font - The font to use
      pos - The position of the lower-left corner
    • drawText

      public void drawText(String text, com.badlogic.gdx.graphics.g2d.BitmapFont font, com.badlogic.gdx.math.Affine2 transform)
      Draws the text on the screen.

      The text will be left-aligned with the origin at the baseline (e.g. the alignment is TextAlign.baselineLeft. The text image will be transformed at this origin.

      This method will draw the font with the current sprite batch color. However, calling this method will erase the current texture.

      Parameters:
      text - The string to draw
      font - The font to use
      transform - The coordinate transform
    • drawText

      public void drawText(TextLayout layout)
      Draws the formatted text on the screen.

      The text origin is defined by TextLayout.getAlignment().

      This method will ignore the sprite batch color and use the color of the text layout. However, calling this method will erase the current texture.

      Parameters:
      layout - The text layout to draw
    • drawText

      public void drawText(TextLayout layout, float x, float y)
      Draws the formatted text on the screen.

      The text origin is defined by TextLayout.getAlignment(). The origin will be offset by the given amount.

      This method will ignore the sprite batch color and use the color of the text layout. However, calling this method will erase the current texture.

      Parameters:
      layout - The text layout to draw
      x - The x-coordinate of the layout origin
      y - The y-coordinate of the layout origin
    • drawText

      public void drawText(TextLayout layout, com.badlogic.gdx.math.Vector2 pos)
      Draws the formatted text on the screen.

      The text origin is defined by TextLayout.getAlignment(). The origin will be offset by the given amount.

      This method will ignore the sprite batch color and use the color of the text layout. However, calling this method will erase the current texture.

      Parameters:
      layout - The text layout to draw
      pos - The position of the layout origin
    • drawText

      public void drawText(TextLayout layout, com.badlogic.gdx.math.Affine2 transform)
      Draws the formatted text on the screen.

      The text origin is defined by TextLayout.getAlignment(). The text image will be transformed at this origin.

      This method will ignore the sprite batch color and use the color of the text layout. However, calling this method will erase the current texture.

      Parameters:
      layout - The text layout to draw
      transform - The transform to apply to the text
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
      Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.

      The rectangle is offset by originX, originY relative to the origin. Scale specifies the scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter clockwise rotation of the rectangle around originX, originY. The portion of the Texture given by srcX, srcY and srcWidth, srcHeight is used. These coordinates and sizes are given in texels. FlipX and flipY specify whether the texture portion should be flipped horizontally or vertically.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      originX - the x-coordinate of the scaling and rotation origin relative to the screen space coordinates
      originY - the y-coordinate of the scaling and rotation origin relative to the screen space coordinates
      width - the width in pixels
      height - the height in pixels
      scaleX - the scale of the rectangle around originX/originY in x
      scaleY - the scale of the rectangle around originX/originY in y
      rotation - the angle of counter clockwise rotation of the rectangle around originX/originY, in degrees
      srcX - the x-coordinate in texel space
      srcY - the y-coordinate in texel space
      srcWidth - the source with in texels
      srcHeight - the source height in texels
      flipX - whether to flip the sprite horizontally
      flipY - whether to flip the sprite vertically
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
      Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.

      The portion of the Texture given by srcX, srcY and srcWidth, srcHeight is used. These coordinates and sizes are given in texels. FlipX and flipY specify whether the texture portion should be flipped horizontally or vertically.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      width - the width in pixels
      height - the height in pixels
      srcX - the x-coordinate in texel space
      srcY - the y-coordinate in texel space
      srcWidth - the source with in texels
      srcHeight - the source height in texels
      flipX - whether to flip the sprite horizontally
      flipY - whether to flip the sprite vertically
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)
      Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.

      The portion of the Texture given by srcX, srcY and srcWidth, srcHeight are used. These coordinates and sizes are given in texels.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      srcX - the x-coordinate in texel space
      srcY - the y-coordinate in texel space
      srcWidth - the source with in texels
      srcHeight - the source height in texels
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2)
      Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels.

      The portion of the Texture given by u, v and u2, v2 are used. These coordinates and sizes are given in texture size percentage. The rectangle will have the given tint Color.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      width - the width in pixels
      height - the height in pixels
      u - the Texture region u value
      v - the Texture region u value
      u2 - the Texture region u2 value
      v2 - the Texture region v2 value
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float x, float y)
      Draws a rectangle with the bottom left corner at x,y having the width and height of the texture.
      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float x, float y, float width, float height)
      Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      width - the image width in screen space
      height - the image height in screen space
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, float[] spriteVertices, int offset, int count)
      Draws a rectangle using the given vertices.

      There must be a multiple of 4 vertices, each made up of 5 elements in this order: x, y, color, u, v. If count is not a multiple of 20 (4 vertices of 5 elements), then any remaining vertices are ignored. The getColor() from the Batch is not applied.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      texture - the image texture
      spriteVertices - the sprite mesh
      offset - the starting offset in spriteVertices
      count - the number of element in spriteVertices to use
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y)
      Draws a rectangle with the bottom left corner at x,y having the width and height of the region.
      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      region - the image texture region
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float width, float height)
      Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      region - the image texture region
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      width - the image width in screen space
      height - the image height in screen space
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
      Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.

      The rectangle is offset by originX, originY relative to the origin. Scale specifies the scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter clockwise rotation of the rectangle around originX, originY.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      region - the image texture region
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      originX - the x-coordinate of the scaling and rotation origin relative to the screen space coordinates
      originY - the y-coordinate of the scaling and rotation origin relative to the screen space coordinates
      width - the width in pixels
      height - the height in pixels
      scaleX - the scale of the rectangle around originX/originY in x
      scaleY - the scale of the rectangle around originX/originY in y
      rotation - the angle of counter clockwise rotation of the rectangle around originX/originY, in degrees
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise)
      Draws a rectangle with the texture coordinates by the given amount.

      The bottom left corner is at x,y and stretches the region to cover the given width and height. The rectangle is offset by originX, originY relative to the origin. Scale specifies the scaling factor by which the rectangle should be scaled around originX, originY. Rotation specifies the angle of counter-clockwise (or clockwise) rotation of the rectangle around originX, originY.

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      region - the image texture region
      x - the x-coordinate in screen space
      y - the y-coordinate in screen space
      originX - the x-coordinate of the scaling and rotation origin relative to the screen space coordinates
      originY - the y-coordinate of the scaling and rotation origin relative to the screen space coordinates
      width - the width in pixels
      height - the height in pixels
      scaleX - the scale of the rectangle around originX/originY in x
      scaleY - the scale of the rectangle around originX/originY in y
      rotation - the angle of rotation of the rectangle around originX/originY, in degrees
      clockwise - whether to rotate clockwise (default is counter clockwise)
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, float width, float height, com.badlogic.gdx.math.Affine2 transform)
      Draws a rectangle transformed by the given matrix.

      The rectangle has the given width and height. The untransformed origin is (0,0)

      Specified by:
      draw in interface com.badlogic.gdx.graphics.g2d.Batch
      Parameters:
      region - the image texture region
      width - the width in pixels
      height - the height in pixels
      transform - the drawing transform
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, Poly2 poly, com.badlogic.gdx.math.Vector2 offset)
      Draws the textured polygon at the given position

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the polygon, offset by the given value.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated, it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture filed, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      texture - The new texture
      poly - The polygon to texture
      offset - The polygon offset
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, Poly2 poly, com.badlogic.gdx.math.Vector2 offset)
      Draws the textured polygon at the given position

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the polygon, offset by the given value.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated, it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture filed, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      region - The new texture region
      poly - The polygon to texture
      offset - The polygon offset
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, Poly2 poly, float x, float y)
      Draws the textured polygon at the given position

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the polygon, offset by the given value.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated, it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture filed, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      texture - The new texture
      poly - The polygon to texture
      x - The polygon x offset
      y - The polygon y offset
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, Poly2 poly, float x, float y)
      Draws the textured polygon at the given position

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the polygon, offset by the given value.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated, it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture filed, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      region - The new texture region
      poly - The polygon to texture
      x - The polygon x offset
      y - The polygon y offset
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, Poly2 poly, com.badlogic.gdx.math.Affine2 transform)
      Draws the given polygon of the texture with the transform.

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the polygon, offset by the given value.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated, it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture filed, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      texture - The new texture
      poly - The polygon to texture
      transform - The drawing transform
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, Poly2 poly, com.badlogic.gdx.math.Affine2 transform)
      Draws the given polygon of the texture with the transform.

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the polygon, offset by the given value.

      The polygon tesselation will be determined by the indices in poly. If the polygon has not been triangulated, it may not draw properly.

      The vertex coordinates will be determined by polygon vertex position. A horizontal position x has texture coordinate x/texture.width. A vertical coordinate has texture coordinate 1-y/texture.height. As a result, a rectangular polygon that has the same dimensions as the texture is the same as simply drawing the texture.

      One way to think of the polygon is as a "cookie cutter". Treat the polygon coordinates as pixel coordinates in the texture filed, and use that to determine how the texture fills the polygon. This may make the polygon larger than you like in order to get the appropriate texturing. You should use one of the transform methods to fix this.

      Parameters:
      region - The new texture region
      poly - The polygon to texture
      transform - The drawing transform
    • draw

      public void draw(com.badlogic.gdx.graphics.Texture texture, com.badlogic.gdx.math.Affine2 transform)
      Draws the the texture with the transform.

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the texture rectangle transformed appropriately.

      Parameters:
      texture - The new texture
      transform - The drawing transform
    • draw

      public void draw(com.badlogic.gdx.graphics.g2d.TextureRegion region, com.badlogic.gdx.math.Affine2 transform)
      Draws the the texture with the transform.

      This is a convenience method that calls the appropriate fill method. It sets the texture, but not the color tint, deleting the previous value. It then draws the texture rectangle transformed appropriately.

      Parameters:
      region - The new texture region
      transform - The drawing transform