public class Quad2D extends Quad
Quad Batchable that supports a single texture at a time, with
two-dimensional position and color. It is designed to be drawn in a 2D plane, and is commonly called a sprite.
The default origin of a Quad2D is its bottom left corner. Its origin is used for positioning, and as the center of rotation and scaling.
It may be subclassed to create a Batchable class that supports zero or multiple textures and additional attributes--see
Quad.getNumberOfTextures() and addVertexAttributes(). Such a
subclass would not be compatible with a FlexBatch that was instantiated for the base Quad2D type.
Batchable.FixedSizeBatchable| Modifier and Type | Field and Description |
|---|---|
float |
rotation |
| Constructor and Description |
|---|
Quad2D() |
| Modifier and Type | Method and Description |
|---|---|
protected int |
apply(float[] vertices,
int vertexStartingIndex,
AttributeOffsets offsets,
int vertexSize)
Called by FlexBatch.
|
Quad2D |
color(com.badlogic.gdx.graphics.Color color) |
Quad2D |
color(float floatBits) |
Quad2D |
color(float r,
float g,
float b,
float a) |
Quad2D |
flip(boolean flipX,
boolean flipY)
Flips the UV region of the most recently applied texture.
|
Quad2D |
flipAll(boolean flipX,
boolean flipY)
Flips the texture region(s) from their current state.
|
protected boolean |
isPosition3D()
Determines whether the position data has a Z component.
|
protected boolean |
isTextureCoordinate3D()
Determines whether the texture coordinate data has a third component (for TextureArray layers).
|
Quad2D |
origin(float originX,
float originY)
Sets the center point for transformations (rotation and scale).
|
Quad2D |
position(float x,
float y)
Sets the position of the bottom left of the texture region in world space.
|
Quad2D |
position(com.badlogic.gdx.math.Vector2 position)
Sets the position of the bottom left of the texture region in world space.
|
protected void |
prepareSharedContext(RenderContextAccumulator renderContext)
Prepares the rendering context for this type of Batchable to be drawn.
|
void |
refresh()
Resets the state and default parameters of the Batchable so it can be reused for an entirely new image.
|
Quad2D |
region(float u,
float v,
float u2,
float v2)
Sets the UV region of the most recently applied texture.
|
Quad2D |
rotateCoordinates90(boolean clockwise)
Rotates the texture region(s) 90 degrees in place by rotating the texture coordinates.
|
Quad2D |
rotation(float rotation) |
Quad2D |
scale(float scaleX,
float scaleY) |
Quad2D |
size(float width,
float height) |
Quad2D |
texture(com.badlogic.gdx.graphics.Texture texture) |
Quad2D |
textureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion region)
Sets the texture region.
|
addVertexAttributes, getNumberOfTextures, getTrianglesPerBatchable, getVerticesPerBatchable, populateTriangleIndices, prepareContext, regionTexels, reset, textureapply, prepareIndicesprotected final boolean isPosition3D()
QuadOverriding this method will produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass type.
isPosition3D in class Quadprotected boolean isTextureCoordinate3D()
QuadOverriding this method will produce a subclass that is incompatible with a FlexBatch that was instantiated for the superclass type.
isTextureCoordinate3D in class Quadprotected void prepareSharedContext(RenderContextAccumulator renderContext)
Batchablebegin(),
executeChanges(), or end() on
renderContext, as these are handled by the FlexBatch. It should not change anything in a way that is unique to any
particular instance of this Batchable type.prepareSharedContext in class BatchablerenderContext - The FlexBatch's manager of GL state changes and texture bindings.public void refresh()
Batchablepublic Quad2D position(float x, float y)
public Quad2D position(com.badlogic.gdx.math.Vector2 position)
public Quad2D rotation(float rotation)
protected int apply(float[] vertices,
int vertexStartingIndex,
AttributeOffsets offsets,
int vertexSize)
Batchableapply in class Quadoffsets - The offsets of the vertex attributes.vertexSize - The size of a vertex in floats.Batchable.FixedSizeBatchable, as it is
assumed to match Batchable.FixedSizeBatchable.getVerticesPerBatchable().public Quad2D texture(com.badlogic.gdx.graphics.Texture texture)
public Quad2D region(float u, float v, float u2, float v2)
QuadQuad.texture(GLTexture) or Quad.textureRegion(TextureRegion). Note that TextureRegions have a Y-down coordinate
system for UVs.
This method must not be called in a Batchable that supports zero textures.
public Quad2D textureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion region)
QuadQuad.texture(GLTexture) will sequentially set the textures in order.
This method must not be called in a Batchable that supports zero textures.
textureRegion in class Quadpublic Quad2D flip(boolean flipX, boolean flipY)
QuadQuad.texture(GLTexture) or Quad.textureRegion(TextureRegion).public Quad2D flipAll(boolean flipX, boolean flipY)
Quadpublic Quad2D rotateCoordinates90(boolean clockwise)
QuadrotateCoordinates90 in class Quad