Batch
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int | |
| private boolean | |
| private int | |
| private int | |
| private final Color | |
| pack-priv float | |
| private final Matrix4 | |
| private Mesh. | |
| private ShaderProgram | |
| public static Mesh. | defaultVertexDataType
Deprecated
Do not use, this field is for testing only and is likely to be removed.
|
| pack-priv boolean | |
| pack-priv int | |
| pack-priv float | |
| pack-priv float | |
| pack-priv Texture | |
| public int | maxSpritesInBatch
The maximum number of sprites rendered in one batch so far. |
| private Mesh | |
| public static Mesh. | overrideVertexType
Deprecated
Used to completely override the vertex type used by SpriteBatch.
|
| private boolean | |
| private final Matrix4 | |
| public int | renderCalls
Number of render calls since the last |
| private final ShaderProgram | |
| public int | totalRenderCalls
Number of rendering calls, ever. |
| private final Matrix4 | |
| pack-priv final float[] |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | SpriteBatch(int
The max number of sprites in a single batch. Max of 8191. size, ShaderProgram The default shader to use. This is not owned by the SpriteBatch and must be disposed separately. defaultShader)Constructs a new SpriteBatch. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public static ShaderProgram | createDefaultShader()
Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified. |
| public void | disableBlending()
Implements com. Disables blending for drawing sprites. |
| public void | dispose()
Implements com. Releases all resources of this object. |
| public void | draw(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)
Implements com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. |
| public void | draw(Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
Implements com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. |
| public void | draw(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)
Implements com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. |
| public void | draw(Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2)
Implements com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. |
| public void | draw(Texture texture, float x, float y)
Implements com. Draws a rectangle with the bottom left corner at x,y having the width and height of the texture. |
| public void | draw(Texture texture, float x, float y, float width, float height)
Implements com. Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height. |
| public void | draw(Texture texture, float[] spriteVertices, int offset, int count)
Implements com. Draws a rectangle using the given vertices. |
| public void | draw(TextureRegion region, float x, float y)
Implements com. Draws a rectangle with the bottom left corner at x,y having the width and height of the region. |
| public void | draw(TextureRegion region, float x, float y, float width, float height)
Implements com. Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height. |
| public void | draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
Implements com. Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height. |
| public void | draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise)
Implements com. Draws a rectangle with the texture coordinates rotated 90 degrees. |
| public void | draw(TextureRegion region, float width, float height, Affine2 transform)
Implements com. Draws a rectangle transformed by the given matrix. |
| public void | enableBlending()
Implements com. Enables blending for drawing sprites. |
| public void | |
| public void | flush()
Implements com. Causes any pending sprites to be rendered, without ending the Batch. |
| public int | |
| public int | |
| public int | |
| public int | |
| public Color | |
| public float | |
| public Matrix4 | getProjectionMatrix()
Implements com. Returns the current projection matrix. |
| public ShaderProgram | |
| public Matrix4 | getTransformMatrix()
Implements com. Returns the current transform matrix. |
| public boolean | |
| public boolean | |
| public void | setBlendFunction(int srcFunc, int dstFunc)
Implements com. Sets the blending function to be used when rendering sprites. |
| public void | setBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha)
Implements com. Sets separate (color/alpha) blending function to be used when rendering sprites. |
| public void | setColor(Color tint)
Implements com. Sets the color used to tint images when they are added to the Batch. |
| public void | setColor(float r, float g, float b, float a)
Implements com.
|
| public void | setPackedColor(float packedColor)
Implements com. Sets the rendering color of this Batch, expanding the alpha from 0-254 to 0-255. |
| public void | setProjectionMatrix(Matrix4 projection)
Implements com. Sets the projection matrix to be used by this Batch. |
| public void | setShader(ShaderProgram shader)
Implements com. Sets the shader to be used in a GLES 2.0 environment. |
| public void | setTransformMatrix(Matrix4 transform)
Implements com. Sets the transform matrix to be used by this Batch. |
| protected void | |
| protected void |
| blendDstFunc | back to summary |
|---|---|
| private int blendDstFunc | |
| blendDstFuncAlpha | back to summary |
|---|---|
| private int blendDstFuncAlpha | |
| blendingDisabled | back to summary |
|---|---|
| private boolean blendingDisabled | |
| blendSrcFunc | back to summary |
|---|---|
| private int blendSrcFunc | |
| blendSrcFuncAlpha | back to summary |
|---|---|
| private int blendSrcFuncAlpha | |
| color | back to summary |
|---|---|
| private final Color color | |
| colorPacked | back to summary |
|---|---|
| pack-priv float colorPacked | |
| combinedMatrix | back to summary |
|---|---|
| private final Matrix4 combinedMatrix | |
| currentDataType | back to summary |
|---|---|
| private Mesh. | |
| customShader | back to summary |
|---|---|
| private ShaderProgram customShader | |
| defaultVertexDataType | back to summary |
|---|---|
| public static Mesh. Deprecated Do not use, this field is for testing only and is likely to be removed. Sets the | |
| drawing | back to summary |
|---|---|
| pack-priv boolean drawing | |
| idx | back to summary |
|---|---|
| pack-priv int idx | |
| invTexHeight | back to summary |
|---|---|
| pack-priv float invTexHeight | |
| invTexWidth | back to summary |
|---|---|
| pack-priv float invTexWidth | |
| lastTexture | back to summary |
|---|---|
| pack-priv Texture lastTexture | |
| maxSpritesInBatch | back to summary |
|---|---|
| public int maxSpritesInBatch The maximum number of sprites rendered in one batch so far. | |
| mesh | back to summary |
|---|---|
| private Mesh mesh | |
| overrideVertexType | back to summary |
|---|---|
| public static Mesh. Deprecated
Used to completely override the vertex type used by SpriteBatch. This is useful for picking a specific vertex data type on construction of the sprite batch. Recommended to reset this back to defaultVertexDataType Once the batch has been created with this flag | |
| ownsShader | back to summary |
|---|---|
| private boolean ownsShader | |
| projectionMatrix | back to summary |
|---|---|
| private final Matrix4 projectionMatrix | |
| renderCalls | back to summary |
|---|---|
| public int renderCalls Number of render calls since the last | |
| shader | back to summary |
|---|---|
| private final ShaderProgram shader | |
| totalRenderCalls | back to summary |
|---|---|
| public int totalRenderCalls Number of rendering calls, ever. Will not be reset unless set manually. | |
| transformMatrix | back to summary |
|---|---|
| private final Matrix4 transformMatrix | |
| vertices | back to summary |
|---|---|
| pack-priv final float[] vertices | |
| SpriteBatch | back to summary |
|---|---|
| public SpriteBatch() Constructs a new SpriteBatch with a size of 1000, one buffer, and the default shader. | |
| SpriteBatch | back to summary |
|---|---|
| public SpriteBatch(int size) Constructs a SpriteBatch with one buffer and the default shader. | |
| SpriteBatch | back to summary |
|---|---|
| public SpriteBatch(int size, ShaderProgram defaultShader) Constructs a new SpriteBatch. Sets the projection matrix to an orthographic projection with y-axis point upwards, x-axis point to the right and the origin being in the bottom left corner of the screen. The projection will be pixel perfect with respect to the current screen resolution.
The defaultShader specifies the shader to use. Note that the names for uniforms for this default shader are different than
the ones expect for shaders set with
| |
| begin | back to summary |
|---|---|
| public void begin() Implements com. Doc from com. Sets up the Batch for drawing. This will disable depth buffer writing. It enables blending and texturing. If you have more
texture units enabled than the first one you have to disable them before calling this. Uses a screen coordinate system by
default where everything is given in pixels. You can specify your own projection and modelview matrices via
| |
| createDefaultShader | back to summary |
|---|---|
| public static ShaderProgram createDefaultShader() Returns a new instance of the default shader used by SpriteBatch for GL2 when no shader is specified. | |
| disableBlending | back to summary |
|---|---|
| public void disableBlending() Implements com. Doc from com. Disables blending for drawing sprites. Calling this within
| |
| dispose | back to summary |
|---|---|
| public void dispose() Implements com. Doc from com. Releases all resources of this object.
| |
| draw | back to summary |
|---|---|
| public void draw(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) Implements com. Doc from com. 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
| |
| draw | back to summary |
|---|---|
| public void draw(Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. The portion of the
| |
| draw | back to summary |
|---|---|
| public void draw(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. The portion of the
| |
| draw | back to summary |
|---|---|
| public void draw(Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y having the given width and height in pixels. The portion of the
| |
| draw | back to summary |
|---|---|
| public void draw(Texture texture, float x, float y) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y having the width and height of the texture.
| |
| draw | back to summary |
|---|---|
| public void draw(Texture texture, float x, float y, float width, float height) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
| |
| draw | back to summary |
|---|---|
| public void draw(Texture texture, float[] spriteVertices, int offset, int count) Implements com. Doc from com. Draws a rectangle using the given vertices. There must be 4 vertices, each made up of 5 elements in this order: x, y,
color, u, v. The
| |
| draw | back to summary |
|---|---|
| public void draw(TextureRegion region, float x, float y) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y having the width and height of the region.
| |
| draw | back to summary |
|---|---|
| public void draw(TextureRegion region, float x, float y, float width, float height) Implements com. Doc from com. Draws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.
| |
| draw | back to summary |
|---|---|
| public void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) Implements com. Doc from com. 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.
| |
| draw | back to summary |
|---|---|
| public void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, boolean clockwise) Implements com. Doc from com. Draws a rectangle with the texture coordinates rotated 90 degrees. 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.
| |
| draw | back to summary |
|---|---|
| public void draw(TextureRegion region, float width, float height, Affine2 transform) Implements com. Doc from com. Draws a rectangle transformed by the given matrix.
| |
| enableBlending | back to summary |
|---|---|
| public void enableBlending() Implements com. Doc from com. Enables blending for drawing sprites. Calling this within
| |
| end | back to summary |
|---|---|
| public void end() Implements com. Doc from com. Finishes off rendering. Enables depth writes, disables blending and texturing. Must always be called after a call to
| |
| flush | back to summary |
|---|---|
| public void flush() Implements com. Doc from com. Causes any pending sprites to be rendered, without ending the Batch.
| |
| getBlendDstFunc | back to summary |
|---|---|
| public int getBlendDstFunc() Implements com.
| |
| getBlendDstFuncAlpha | back to summary |
|---|---|
| public int getBlendDstFuncAlpha() Implements com.
| |
| getBlendSrcFunc | back to summary |
|---|---|
| public int getBlendSrcFunc() Implements com.
| |
| getBlendSrcFuncAlpha | back to summary |
|---|---|
| public int getBlendSrcFuncAlpha() Implements com.
| |
| getColor | back to summary |
|---|---|
| public Color getColor() Implements com.
| |
| getPackedColor | back to summary |
|---|---|
| public float getPackedColor() Implements com.
| |
| getProjectionMatrix | back to summary |
|---|---|
| public Matrix4 getProjectionMatrix() Implements com. Doc from com. Returns the current projection matrix. Changing this within
| |
| getShader | back to summary |
|---|---|
| public ShaderProgram getShader() Implements com.
| |
| getTransformMatrix | back to summary |
|---|---|
| public Matrix4 getTransformMatrix() Implements com. Doc from com. Returns the current transform matrix. Changing this within
| |
| isBlendingEnabled | back to summary |
|---|---|
| public boolean isBlendingEnabled() Implements com.
| |
| isDrawing | back to summary |
|---|---|
| public boolean isDrawing() Implements com. | |
| setBlendFunction | back to summary |
|---|---|
| public void setBlendFunction(int srcFunc, int dstFunc) Implements com. Doc from com. Sets the blending function to be used when rendering sprites.
| |
| setBlendFunctionSeparate | back to summary |
|---|---|
| public void setBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha) Implements com. Doc from com. Sets separate (color/alpha) blending function to be used when rendering sprites.
| |
| setColor | back to summary |
|---|---|
| public void setColor(Color tint) Implements com. Doc from com. Sets the color used to tint images when they are added to the Batch. Default is
| |
| setColor | back to summary |
|---|---|
| public void setColor(float r, float g, float b, float a) Implements com.
| |
| setPackedColor | back to summary |
|---|---|
| public void setPackedColor(float packedColor) Implements com. Doc from com. Sets the rendering color of this Batch, expanding the alpha from 0-254 to 0-255.
| |
| setProjectionMatrix | back to summary |
|---|---|
| public void setProjectionMatrix(Matrix4 projection) Implements com. Doc from com. Sets the projection matrix to be used by this Batch. If this is called inside a
| |
| setShader | back to summary |
|---|---|
| public void setShader(ShaderProgram shader) Implements com. Doc from com. Sets the shader to be used in a GLES 2.0 environment. Vertex position attribute is called "a_position", the texture
coordinates attribute is called "a_texCoord0", the color attribute is called "a_color". See
Call this method with a null argument to use the default shader.
This method will flush the batch before setting the new shader, you can call it in between
| |
| setTransformMatrix | back to summary |
|---|---|
| public void setTransformMatrix(Matrix4 transform) Implements com. Doc from com. Sets the transform matrix to be used by this Batch.
| |
| setupMatrices | back to summary |
|---|---|
| protected void setupMatrices() | |
| switchTexture | back to summary |
|---|---|
| protected void switchTexture(Texture texture) | |