Package com.prineside.tdi2.utils
Class SpriteCacheExtended
java.lang.Object
com.badlogic.gdx.graphics.g2d.SpriteCache
com.prineside.tdi2.utils.SpriteCacheExtended
- All Implemented Interfaces:
 Batch,Disposable
May also act like a Batch but will store vertex data into cache.
 Batch's methods related to blending won't work and will throw an exception (blending should be applied
 during the rendering stage, not while mesh generation).
 If some batch is specified by setOutputToBatch(), Batch-defined methods will be redirected there.
- 
Nested Class Summary
Nested Classes - 
Field Summary
FieldsModifier and TypeFieldDescriptionintintfinal intfinal intfinal booleanfinal intFields inherited from class com.badlogic.gdx.graphics.g2d.SpriteCache
renderCalls, totalRenderCalls - 
Constructor Summary
ConstructorsConstructorDescriptionSpriteCacheExtended(String name, int size, ShaderProgram shaderProgram, boolean useIndices)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified vertices to the cache.voidStarts the definition of a new cache, allowing the add andSpriteCache.endCache()methods to be called.voidclear()Invalidates all cache IDs and resets the SpriteCache so new caches can be added.static ShaderProgramTaken from SpriteCachevoidDisables blending for drawing sprites.voiddraw(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.voiddraw(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.voiddraw(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.voiddraw(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 rotated 90 degrees.voiddraw(TextureRegion region, float width, float height, Affine2 transform) Draws a rectangle transformed by the given matrix.voidDraws a rectangle using the given vertices.voidDraws a rectangle with the bottom left corner at x,y having the width and height of the texture.voidDraws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height.voiddraw(Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2) Deprecated.SpriteCache#add(Texture texture, float x, float y, int srcWidth, int srcHeight, float u, float v, float u2, float v2, float color) may be broken / inconsistent (srcWidth/Height define actual size and not the source size), better use some other method.voiddraw(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.voiddraw(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.voidDraws a rectangle with the bottom left corner at x,y having the given width and height in pixels.voidEnables blending for drawing sprites.intendCache()Ends the definition of a cache, returning the cache ID to be used withSpriteCache.draw(int).voidflush()Causes any pending sprites to be rendered, without ending the Batch.intintintintbooleanbooleanisFull()voidsetAlphaMultiplier(float fixedAlpha) voidsetBlendFunction(int srcFunc, int dstFunc) Sets the blending function to be used when rendering sprites.voidsetBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha) Sets separate (color/alpha) blending function to be used when rendering sprites.voidsetOutputToBatch(Batch batch) Redirects all of the calls to the specified batch SpriteCache begins to act like a regular batch Batch uses indicesMethods inherited from class com.badlogic.gdx.graphics.g2d.SpriteCache
add, add, add, add, add, add, add, add, add, begin, beginCache, dispose, draw, draw, end, getColor, getCustomShader, getPackedColor, getProjectionMatrix, getTransformMatrix, isDrawing, setColor, setColor, setPackedColor, setProjectionMatrix, setShader, setTransformMatrixMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.badlogic.gdx.graphics.g2d.Batch
begin, end, getColor, getPackedColor, getProjectionMatrix, getTransformMatrix, isDrawing, setColor, setColor, setPackedColor, setProjectionMatrix, setShader, setTransformMatrixMethods inherited from interface com.badlogic.gdx.utils.Disposable
dispose 
- 
Field Details
- 
useIndices
public final boolean useIndices - 
vertexPerAdd
public final int vertexPerAdd - 
size
public final int size - 
maxAdds
public final int maxAdds - 
addCount
public int addCount - 
lastCacheId
public int lastCacheId 
 - 
 - 
Constructor Details
- 
SpriteCacheExtended
 
 - 
 - 
Method Details
- 
setOutputToBatch
Redirects all of the calls to the specified batch SpriteCache begins to act like a regular batch Batch uses indices - 
setAlphaMultiplier
public void setAlphaMultiplier(float fixedAlpha)  - 
createDefaultShader
Taken from SpriteCache - 
add
Description copied from class:com.badlogic.gdx.graphics.g2d.SpriteCacheAdds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color, u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be specified as 6 vertices.- Overrides:
 addin classSpriteCache
 - 
beginCache
public void beginCache()Description copied from class:com.badlogic.gdx.graphics.g2d.SpriteCacheStarts the definition of a new cache, allowing the add andSpriteCache.endCache()methods to be called.- Overrides:
 beginCachein classSpriteCache
 - 
isFull
public boolean isFull() - 
endCache
public int endCache()Description copied from class:com.badlogic.gdx.graphics.g2d.SpriteCacheEnds the definition of a cache, returning the cache ID to be used withSpriteCache.draw(int).- Overrides:
 endCachein classSpriteCache
 - 
clear
public void clear()Description copied from class:com.badlogic.gdx.graphics.g2d.SpriteCacheInvalidates all cache IDs and resets the SpriteCache so new caches can be added.- Overrides:
 clearin classSpriteCache
 - 
draw
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) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws 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 theTexturegiven 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:
 drawin interfaceBatchx- the x-coordinate in screen spacey- the y-coordinate in screen spaceoriginX- the x-coordinate of the scaling and rotation origin relative to the screen space coordinatesoriginY- the y-coordinate of the scaling and rotation origin relative to the screen space coordinateswidth- the width in pixelsheight- the height in pixelsscaleX- the scale of the rectangle around originX/originY in xscaleY- the scale of the rectangle around originX/originY in yrotation- the angle of counter clockwise rotation of the rectangle around originX/originY, in degreessrcX- the x-coordinate in texel spacesrcY- the y-coordinate in texel spacesrcWidth- the source with in texelssrcHeight- the source height in texelsflipX- whether to flip the sprite horizontallyflipY- whether to flip the sprite vertically
 - 
draw
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) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle with the bottom left corner at x,y having the given width and height in pixels. The portion of theTexturegiven 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:
 drawin interfaceBatchx- the x-coordinate in screen spacey- the y-coordinate in screen spacewidth- the width in pixelsheight- the height in pixelssrcX- the x-coordinate in texel spacesrcY- the y-coordinate in texel spacesrcWidth- the source with in texelssrcHeight- the source height in texelsflipX- whether to flip the sprite horizontallyflipY- whether to flip the sprite vertically
 - 
draw
public void draw(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle with the bottom left corner at x,y having the given width and height in pixels. The portion of theTexturegiven by srcX, srcY and srcWidth, srcHeight are used. These coordinates and sizes are given in texels. - 
draw
@Deprecated public void draw(Texture texture, float x, float y, float width, float height, float u, float v, float u2, float v2) Deprecated.SpriteCache#add(Texture texture, float x, float y, int srcWidth, int srcHeight, float u, float v, float u2, float v2, float color) may be broken / inconsistent (srcWidth/Height define actual size and not the source size), better use some other method.Description copied from interface:com.badlogic.gdx.graphics.g2d.Batch - 
draw
Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle with the bottom left corner at x,y having the width and height of the texture. - 
draw
Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height. - 
draw
Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws 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. TheBatch.getColor()from the Batch is not applied. - 
draw
Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle with the bottom left corner at x,y having the width and height of the region. - 
draw
Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle with the bottom left corner at x,y and stretching the region to cover the given width and height. - 
draw
public void draw(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws 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
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) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws 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
Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDraws a rectangle transformed by the given matrix. - 
flush
public void flush()Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchCauses any pending sprites to be rendered, without ending the Batch. - 
disableBlending
public void disableBlending()Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchDisables blending for drawing sprites. Calling this withinBatch.begin()/Batch.end()will flush the batch.- Specified by:
 disableBlendingin interfaceBatch
 - 
enableBlending
public void enableBlending()Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchEnables blending for drawing sprites. Calling this withinBatch.begin()/Batch.end()will flush the batch.- Specified by:
 enableBlendingin interfaceBatch
 - 
setBlendFunction
public void setBlendFunction(int srcFunc, int dstFunc) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchSets the blending function to be used when rendering sprites.- Specified by:
 setBlendFunctionin interfaceBatch- Parameters:
 srcFunc- the source function, e.g. GL20.GL_SRC_ALPHA. If set to -1, Batch won't change the blending function.dstFunc- the destination function, e.g. GL20.GL_ONE_MINUS_SRC_ALPHA
 - 
setBlendFunctionSeparate
public void setBlendFunctionSeparate(int srcFuncColor, int dstFuncColor, int srcFuncAlpha, int dstFuncAlpha) Description copied from interface:com.badlogic.gdx.graphics.g2d.BatchSets separate (color/alpha) blending function to be used when rendering sprites.- Specified by:
 setBlendFunctionSeparatein interfaceBatch- Parameters:
 srcFuncColor- the source color function, e.g. GL20.GL_SRC_ALPHA. If set to -1, Batch won't change the blending function.dstFuncColor- the destination color function, e.g. GL20.GL_ONE_MINUS_SRC_ALPHA.srcFuncAlpha- the source alpha function, e.g. GL20.GL_SRC_ALPHA.dstFuncAlpha- the destination alpha function, e.g. GL20.GL_ONE_MINUS_SRC_ALPHA.
 - 
getBlendSrcFunc
public int getBlendSrcFunc()- Specified by:
 getBlendSrcFuncin interfaceBatch
 - 
getBlendDstFunc
public int getBlendDstFunc()- Specified by:
 getBlendDstFuncin interfaceBatch
 - 
getBlendSrcFuncAlpha
public int getBlendSrcFuncAlpha()- Specified by:
 getBlendSrcFuncAlphain interfaceBatch
 - 
getBlendDstFuncAlpha
public int getBlendDstFuncAlpha()- Specified by:
 getBlendDstFuncAlphain interfaceBatch
 - 
getShader
- Specified by:
 getShaderin interfaceBatch- Returns:
 - the current 
ShaderProgramset byBatch.setShader(ShaderProgram)or the defaultShader 
 - 
isBlendingEnabled
public boolean isBlendingEnabled()- Specified by:
 isBlendingEnabledin interfaceBatch- Returns:
 - true if blending for sprites is enabled
 
 
 -