<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_17) on Sun Nov 03 15:35:45 CET 2013 -->
<title>SpriteCache (libgdx API)
</title>
<meta name="date" content="2013-11-03">
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="SpriteCache (libgdx API)";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.
</div>
</noscript>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a name="navbar_top">
<!-- -->
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview
</a></li>
<li><a href="package-summary.html">Package
</a></li>
<li class="navBarCell1Rev">Class
</li>
<li><a href="class-use/SpriteCache.html">Use
</a></li>
<li><a href="package-tree.html">Tree
</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated
</a></li>
<li><a href="../../../../../index-all.html">Index
</a></li>
<li><a href="../../../../../help-doc.html">Help
</a></li>
</ul>
<div class="aboutLanguage"><em>
libgdx API
<style>
body, td, th { font-family:Helvetica, Tahoma, Arial, sans-serif; font-size:10pt }
pre, code, tt { font-size:9pt; font-family:Lucida Console, Courier New, sans-serif }
h1, h2, h3, .FrameTitleFont, .FrameHeadingFont, .TableHeadingColor font { font-size:105%; font-weight:bold }
.TableHeadingColor { background:#EEEEFF; }
a { text-decoration:none }
a:hover { text-decoration:underline }
a:link, a:visited { color:blue }
table { border:0px }
.TableRowColor td:first-child { border-left:1px solid black }
.TableRowColor td { border:0px; border-bottom:1px solid black; border-right:1px solid black }
hr { border:0px; border-bottom:1px solid #333366; }
</style>
</em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteBatch.html" title="class in com.badlogic.gdx.graphics.g2d"><span class="strong">Prev Class
</span></a></li>
<li><a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureAtlas.html" title="class in com.badlogic.gdx.graphics.g2d"><span class="strong">Next Class
</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?com/badlogic/gdx/graphics/g2d/SpriteCache.html" target="_top">Frames
</a></li>
<li><a href="SpriteCache.html" target="_top">No Frames
</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../../allclasses-noframe.html">All Classes
</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:
</li>
<li>Nested
|
</li>
<li>Field
|
</li>
<li><a href="#constructor_summary">Constr
</a> |
</li>
<li><a href="#method_summary">Method
</a></li>
</ul>
<ul class="subNavList">
<li>Detail:
</li>
<li>Field
|
</li>
<li><a href="#constructor_detail">Constr
</a> |
</li>
<li><a href="#method_detail">Method
</a></li>
</ul>
</div>
<a name="skip-navbar_top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<div class="subTitle">com.badlogic.gdx.graphics.g2d
</div>
<h2 title="Class SpriteCache" class="title">Class SpriteCache
</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object
</li>
<li>
<ul class="inheritance">
<li>com.badlogic.gdx.graphics.g2d.SpriteCache
</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>All Implemented Interfaces:
</dt>
<dd><a href="../../../../../com/badlogic/gdx/utils/Disposable.html" title="interface in com.badlogic.gdx.utils">Disposable
</a></dd>
</dl>
<hr>
<br>
<pre>public class
<span class="strong">SpriteCache
</span>
extends java.lang.Object
implements
<a href="../../../../../com/badlogic/gdx/utils/Disposable.html" title="interface in com.badlogic.gdx.utils">Disposable
</a></pre>
<div class="block">Draws 2D images, optimized for geometry that does not change. Sprites and/or textures are cached and given an ID, which can
later be used for drawing. The size, color, and texture region for each cached image cannot be modified. This information is
stored in video memory and does not have to be sent to the GPU each time it is drawn.
<br>
<br>
To cache
<a href="../../../../../com/badlogic/gdx/graphics/g2d/Sprite.html" title="class in com.badlogic.gdx.graphics.g2d"><code>sprites
</code></a> or
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics"><code>textures
</code></a>, first call
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#beginCache()"><code>beginCache()
</code></a>, then call the
appropriate add method to define the images. To complete the cache, call
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#endCache()"><code>endCache()
</code></a> and store the returned
cache ID.
<br>
<br>
To draw with SpriteCache, first call
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#begin()"><code>begin()
</code></a>, then call
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#draw(int)"><code>draw(int)
</code></a> with a cache ID. When SpriteCache drawing
is complete, call
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#end()"><code>end()
</code></a>.
<br>
<br>
By default, SpriteCache draws using screen coordinates and uses an x-axis pointing to the right, an y-axis pointing upwards and
the origin is the bottom left corner of the screen. The default transformation and projection matrices can be changed. If the
screen is
<a href="../../../../../com/badlogic/gdx/ApplicationListener.html#resize(int, int)"><code>resized
</code></a>, the SpriteCache's matrices must be updated. For example:
<br>
<code>cache.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
</code><br>
<br>
Note that SpriteCache does not manage blending. You will need to enable blending (
<i>Gdx.gl.glEnable(GL10.GL_BLEND);
</i>) and
set the blend func as needed before or between calls to
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#draw(int)"><code>draw(int)
</code></a>.
<br>
<br>
SpriteCache is managed. If the OpenGL context is lost and the restored, all OpenGL resources a SpriteCache uses internally are
restored.
<br>
<br>
SpriteCache is a reasonably heavyweight object. Typically only one instance should be used for an entire application.
<br>
<br>
SpriteCache works with OpenGL ES 1.x and 2.0. For 2.0, it uses its own custom shader to draw.
<br>
<br>
SpriteCache must be disposed once it is no longer needed.
</div>
<dl><dt><span class="strong">Author:
</span></dt>
<dd>Nathan Sweet
</dd></dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- ======== CONSTRUCTOR SUMMARY ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_summary">
<!-- -->
</a>
<h3>Constructor Summary
</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
<caption><span>Constructors
</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colOne" scope="col">Constructor and Description
</th>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#SpriteCache()">SpriteCache
</a></strong>()
</code>
<div class="block">Creates a cache that uses indexed geometry and can contain up to 1000 images.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colOne"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#SpriteCache(int, boolean)">SpriteCache
</a></strong>(int
size,
boolean
useIndices)
</code>
<div class="block">Creates a cache with the specified size, using a default shader if OpenGL ES 2.0 is being used.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colOne"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#SpriteCache(int, com.badlogic.gdx.graphics.glutils.ShaderProgram, boolean)">SpriteCache
</a></strong>(int
size,
<a href="../../../../../com/badlogic/gdx/graphics/glutils/ShaderProgram.html" title="class in com.badlogic.gdx.graphics.glutils">ShaderProgram
</a> shader,
boolean
useIndices)
</code>
<div class="block">Creates a cache with the specified size and OpenGL ES 2.0 shader.
</div>
</td>
</tr>
</table>
</li>
</ul>
<!-- ========== METHOD SUMMARY =========== -->
<ul class="blockList">
<li class="blockList"><a name="method_summary">
<!-- -->
</a>
<h3>Method Summary
</h3>
<table class="overviewSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
<caption><span>Methods
</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type
</th>
<th class="colLast" scope="col">Method and Description
</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.g2d.Sprite)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/Sprite.html" title="class in com.badlogic.gdx.graphics.g2d">Sprite
</a> sprite)
</code>
<div class="block">Adds the specified sprite to the cache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.Texture, float[], int, int)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float[]
vertices,
int
offset,
int
length)
</code>
<div class="block">Adds the specified vertices to the cache.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.Texture, float, float)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y)
</code>
<div class="block">Adds the specified texture to the cache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.Texture, float, float, float, float, float, float, float, float, float, int, int, int, int, boolean, boolean)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> 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)
</code>
<div class="block">Adds the specified texture to the cache.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.Texture, float, float, float, float, int, int, int, int, boolean, boolean)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y,
float
width,
float
height,
int
srcX,
int
srcY,
int
srcWidth,
int
srcHeight,
boolean
flipX,
boolean
flipY)
</code>
<div class="block">Adds the specified texture to the cache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.Texture, float, float, int, int, float, float, float, float, float)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y,
int
srcWidth,
int
srcHeight,
float
u,
float
v,
float
u2,
float
v2,
float
color)
</code>
<div class="block">Adds the specified texture to the cache.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.Texture, float, float, int, int, int, int)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y,
int
srcX,
int
srcY,
int
srcWidth,
int
srcHeight)
</code>
<div class="block">Adds the specified texture to the cache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureRegion.html" title="class in com.badlogic.gdx.graphics.g2d">TextureRegion
</a> region,
float
x,
float
y)
</code>
<div class="block">Adds the specified region to the cache.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float, float, float)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureRegion.html" title="class in com.badlogic.gdx.graphics.g2d">TextureRegion
</a> region,
float
x,
float
y,
float
width,
float
height)
</code>
<div class="block">Adds the specified region to the cache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#add(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float, float, float, float, float, float, float, float)">add
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureRegion.html" title="class in com.badlogic.gdx.graphics.g2d">TextureRegion
</a> region,
float
x,
float
y,
float
originX,
float
originY,
float
width,
float
height,
float
scaleX,
float
scaleY,
float
rotation)
</code>
<div class="block">Adds the specified region to the cache.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#begin()">begin
</a></strong>()
</code>
<div class="block">Prepares the OpenGL state for SpriteCache rendering.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#beginCache()">beginCache
</a></strong>()
</code>
<div class="block">Starts the definition of a new cache, allowing the add and
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#endCache()"><code>endCache()
</code></a> methods to be called.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#beginCache(int)">beginCache
</a></strong>(int
cacheID)
</code>
<div class="block">Starts the redefinition of an existing cache, allowing the add and
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#endCache()"><code>endCache()
</code></a> methods to be called.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#clear()">clear
</a></strong>()
</code>
<div class="block">Invalidates all cache IDs and resets the SpriteCache so new caches can be added.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#dispose()">dispose
</a></strong>()
</code>
<div class="block">Releases all resources held by this SpriteCache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#draw(int)">draw
</a></strong>(int
cacheID)
</code>
<div class="block">Draws all the images defined for the specified cache ID.
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#draw(int, int, int)">draw
</a></strong>(int
cacheID,
int
offset,
int
length)
</code>
<div class="block">Draws a subset of images defined for the specified cache ID.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#end()">end
</a></strong>()
</code>
<div class="block">Completes rendering for this SpriteCache.f
</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>int
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#endCache()">endCache
</a></strong>()
</code>
<div class="block">Ends the definition of a cache, returning the cache ID to be used with
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#draw(int)"><code>draw(int)
</code></a>.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../com/badlogic/gdx/graphics/Color.html" title="class in com.badlogic.gdx.graphics">Color
</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#getColor()">getColor
</a></strong>()
</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#getProjectionMatrix()">getProjectionMatrix
</a></strong>()
</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a></code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#getTransformMatrix()">getTransformMatrix
</a></strong>()
</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setColor(com.badlogic.gdx.graphics.Color)">setColor
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/Color.html" title="class in com.badlogic.gdx.graphics">Color
</a> tint)
</code>
<div class="block">Sets the color used to tint images when they are added to the SpriteCache.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setColor(float)">setColor
</a></strong>(float
color)
</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setColor(float, float, float, float)">setColor
</a></strong>(float
r,
float
g,
float
b,
float
a)
</code> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setProjectionMatrix(com.badlogic.gdx.math.Matrix4)">setProjectionMatrix
</a></strong>(
<a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a> projection)
</code> </td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setShader(com.badlogic.gdx.graphics.glutils.ShaderProgram)">setShader
</a></strong>(
<a href="../../../../../com/badlogic/gdx/graphics/glutils/ShaderProgram.html" title="class in com.badlogic.gdx.graphics.glutils">ShaderProgram
</a> shader)
</code>
<div class="block">Sets the shader to be used in a GLES 2.0 environment.
</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code>void
</code></td>
<td class="colLast"><code><strong><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setTransformMatrix(com.badlogic.gdx.math.Matrix4)">setTransformMatrix
</a></strong>(
<a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a> transform)
</code> </td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods_inherited_from_class_java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class
java.lang.Object
</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ========= CONSTRUCTOR DETAIL ======== -->
<ul class="blockList">
<li class="blockList"><a name="constructor_detail">
<!-- -->
</a>
<h3>Constructor Detail
</h3>
<a name="SpriteCache()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SpriteCache
</h4>
<pre>public
SpriteCache()
</pre>
<div class="block">Creates a cache that uses indexed geometry and can contain up to 1000 images.
</div>
</li>
</ul>
<a name="SpriteCache(int, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>SpriteCache
</h4>
<pre>public
SpriteCache(int
size,
boolean
useIndices)
</pre>
<div class="block">Creates a cache with the specified size, using a default shader if OpenGL ES 2.0 is being used.
</div>
<dl><dt><span class="strong">Parameters:
</span></dt><dd><code>size
</code> - The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
</dd><dd><code>useIndices
</code> - If true, indexed geometry will be used.
</dd></dl>
</li>
</ul>
<a name="SpriteCache(int, com.badlogic.gdx.graphics.glutils.ShaderProgram, boolean)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>SpriteCache
</h4>
<pre>public
SpriteCache(int
size,
<a href="../../../../../com/badlogic/gdx/graphics/glutils/ShaderProgram.html" title="class in com.badlogic.gdx.graphics.glutils">ShaderProgram
</a> shader,
boolean
useIndices)
</pre>
<div class="block">Creates a cache with the specified size and OpenGL ES 2.0 shader.
</div>
<dl><dt><span class="strong">Parameters:
</span></dt><dd><code>size
</code> - The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
</dd><dd><code>useIndices
</code> - If true, indexed geometry will be used.
</dd></dl>
</li>
</ul>
</li>
</ul>
<!-- ============ METHOD DETAIL ========== -->
<ul class="blockList">
<li class="blockList"><a name="method_detail">
<!-- -->
</a>
<h3>Method Detail
</h3>
<a name="setColor(com.badlogic.gdx.graphics.Color)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setColor
</h4>
<pre>public
void
setColor(
<a href="../../../../../com/badlogic/gdx/graphics/Color.html" title="class in com.badlogic.gdx.graphics">Color
</a> tint)
</pre>
<div class="block">Sets the color used to tint images when they are added to the SpriteCache. Default is
<a href="../../../../../com/badlogic/gdx/graphics/Color.html#WHITE"><code>Color.WHITE
</code></a>.
</div>
</li>
</ul>
<a name="setColor(float, float, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setColor
</h4>
<pre>public
void
setColor(float
r,
float
g,
float
b,
float
a)
</pre>
<dl><dt><span class="strong">See Also:
</span></dt><dd><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setColor(com.badlogic.gdx.graphics.Color)"><code>setColor(Color)
</code></a></dd></dl>
</li>
</ul>
<a name="setColor(float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setColor
</h4>
<pre>public
void
setColor(float
color)
</pre>
<dl><dt><span class="strong">See Also:
</span></dt><dd><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#setColor(com.badlogic.gdx.graphics.Color)"><code>setColor(Color)
</code></a>,
<a href="../../../../../com/badlogic/gdx/graphics/Color.html#toFloatBits()"><code>Color.toFloatBits()
</code></a></dd></dl>
</li>
</ul>
<a name="getColor()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getColor
</h4>
<pre>public
<a href="../../../../../com/badlogic/gdx/graphics/Color.html" title="class in com.badlogic.gdx.graphics">Color
</a> getColor()
</pre>
</li>
</ul>
<a name="beginCache()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>beginCache
</h4>
<pre>public
void
beginCache()
</pre>
<div class="block">Starts the definition of a new cache, allowing the add and
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#endCache()"><code>endCache()
</code></a> methods to be called.
</div>
</li>
</ul>
<a name="beginCache(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>beginCache
</h4>
<pre>public
void
beginCache(int
cacheID)
</pre>
<div class="block">Starts the redefinition of an existing cache, allowing the add and
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#endCache()"><code>endCache()
</code></a> methods to be called. If this is not
the last cache created, it cannot have more entries added to it than when it was first created. To do that, use
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#clear()"><code>clear()
</code></a> and then
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#begin()"><code>begin()
</code></a>.
</div>
</li>
</ul>
<a name="endCache()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>endCache
</h4>
<pre>public
int
endCache()
</pre>
<div class="block">Ends the definition of a cache, returning the cache ID to be used with
<a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteCache.html#draw(int)"><code>draw(int)
</code></a>.
</div>
</li>
</ul>
<a name="clear()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>clear
</h4>
<pre>public
void
clear()
</pre>
<div class="block">Invalidates all cache IDs and resets the SpriteCache so new caches can be added.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.Texture, float[], int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float[]
vertices,
int
offset,
int
length)
</pre>
<div class="block">Adds 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.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.Texture, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y)
</pre>
<div class="block">Adds the specified texture to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.Texture, float, float, int, int, float, float, float, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y,
int
srcWidth,
int
srcHeight,
float
u,
float
v,
float
u2,
float
v2,
float
color)
</pre>
<div class="block">Adds the specified texture to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.Texture, float, float, int, int, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y,
int
srcX,
int
srcY,
int
srcWidth,
int
srcHeight)
</pre>
<div class="block">Adds the specified texture to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.Texture, float, float, float, float, int, int, int, int, boolean, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> texture,
float
x,
float
y,
float
width,
float
height,
int
srcX,
int
srcY,
int
srcWidth,
int
srcHeight,
boolean
flipX,
boolean
flipY)
</pre>
<div class="block">Adds the specified texture to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.Texture, float, float, float, float, float, float, float, float, float, int, int, int, int, boolean, boolean)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/Texture.html" title="class in com.badlogic.gdx.graphics">Texture
</a> 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)
</pre>
<div class="block">Adds the specified texture to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureRegion.html" title="class in com.badlogic.gdx.graphics.g2d">TextureRegion
</a> region,
float
x,
float
y)
</pre>
<div class="block">Adds the specified region to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureRegion.html" title="class in com.badlogic.gdx.graphics.g2d">TextureRegion
</a> region,
float
x,
float
y,
float
width,
float
height)
</pre>
<div class="block">Adds the specified region to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.g2d.TextureRegion, float, float, float, float, float, float, float, float, float)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureRegion.html" title="class in com.badlogic.gdx.graphics.g2d">TextureRegion
</a> region,
float
x,
float
y,
float
originX,
float
originY,
float
width,
float
height,
float
scaleX,
float
scaleY,
float
rotation)
</pre>
<div class="block">Adds the specified region to the cache.
</div>
</li>
</ul>
<a name="add(com.badlogic.gdx.graphics.g2d.Sprite)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>add
</h4>
<pre>public
void
add(
<a href="../../../../../com/badlogic/gdx/graphics/g2d/Sprite.html" title="class in com.badlogic.gdx.graphics.g2d">Sprite
</a> sprite)
</pre>
<div class="block">Adds the specified sprite to the cache.
</div>
</li>
</ul>
<a name="begin()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>begin
</h4>
<pre>public
void
begin()
</pre>
<div class="block">Prepares the OpenGL state for SpriteCache rendering.
</div>
</li>
</ul>
<a name="end()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>end
</h4>
<pre>public
void
end()
</pre>
<div class="block">Completes rendering for this SpriteCache.f
</div>
</li>
</ul>
<a name="draw(int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>draw
</h4>
<pre>public
void
draw(int
cacheID)
</pre>
<div class="block">Draws all the images defined for the specified cache ID.
</div>
</li>
</ul>
<a name="draw(int, int, int)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>draw
</h4>
<pre>public
void
draw(int
cacheID,
int
offset,
int
length)
</pre>
<div class="block">Draws a subset of images defined for the specified cache ID.
</div>
<dl><dt><span class="strong">Parameters:
</span></dt><dd><code>offset
</code> - The first image to render.
</dd><dd><code>length
</code> - The number of images from the first image (inclusive) to render.
</dd></dl>
</li>
</ul>
<a name="dispose()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>dispose
</h4>
<pre>public
void
dispose()
</pre>
<div class="block">Releases all resources held by this SpriteCache.
</div>
<dl>
<dt><strong>Specified by:
</strong></dt>
<dd><code><a href="../../../../../com/badlogic/gdx/utils/Disposable.html#dispose()">dispose
</a></code> in interface
<code><a href="../../../../../com/badlogic/gdx/utils/Disposable.html" title="interface in com.badlogic.gdx.utils">Disposable
</a></code></dd>
</dl>
</li>
</ul>
<a name="getProjectionMatrix()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getProjectionMatrix
</h4>
<pre>public
<a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a> getProjectionMatrix()
</pre>
</li>
</ul>
<a name="setProjectionMatrix(com.badlogic.gdx.math.Matrix4)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setProjectionMatrix
</h4>
<pre>public
void
setProjectionMatrix(
<a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a> projection)
</pre>
</li>
</ul>
<a name="getTransformMatrix()">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getTransformMatrix
</h4>
<pre>public
<a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a> getTransformMatrix()
</pre>
</li>
</ul>
<a name="setTransformMatrix(com.badlogic.gdx.math.Matrix4)">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>setTransformMatrix
</h4>
<pre>public
void
setTransformMatrix(
<a href="../../../../../com/badlogic/gdx/math/Matrix4.html" title="class in com.badlogic.gdx.math">Matrix4
</a> transform)
</pre>
</li>
</ul>
<a name="setShader(com.badlogic.gdx.graphics.glutils.ShaderProgram)">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>setShader
</h4>
<pre>public
void
setShader(
<a href="../../../../../com/badlogic/gdx/graphics/glutils/ShaderProgram.html" title="class in com.badlogic.gdx.graphics.glutils">ShaderProgram
</a> shader)
</pre>
<div class="block">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 called "a_texCoords", the color attribute is called "a_color". The projection matrix is
uploaded via a mat4 uniform called "u_proj", the transform matrix is uploaded via a uniform called "u_trans", the combined
transform and projection matrx is is uploaded via a mat4 uniform called "u_projTrans". The texture sampler is passed via a
uniform called "u_texture".
Call this method with a null argument to use the default shader.
</div>
<dl><dt><span class="strong">Parameters:
</span></dt><dd><code>shader
</code> - the
<a href="../../../../../com/badlogic/gdx/graphics/glutils/ShaderProgram.html" title="class in com.badlogic.gdx.graphics.glutils"><code>ShaderProgram
</code></a> or null to use the default shader.
</dd></dl>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- ========= END OF CLASS DATA ========= -->
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a name="navbar_bottom">
<!-- -->
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../../overview-summary.html">Overview
</a></li>
<li><a href="package-summary.html">Package
</a></li>
<li class="navBarCell1Rev">Class
</li>
<li><a href="class-use/SpriteCache.html">Use
</a></li>
<li><a href="package-tree.html">Tree
</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated
</a></li>
<li><a href="../../../../../index-all.html">Index
</a></li>
<li><a href="../../../../../help-doc.html">Help
</a></li>
</ul>
<div class="aboutLanguage"><em>libgdx API
</em></div>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../../../../../com/badlogic/gdx/graphics/g2d/SpriteBatch.html" title="class in com.badlogic.gdx.graphics.g2d"><span class="strong">Prev Class
</span></a></li>
<li><a href="../../../../../com/badlogic/gdx/graphics/g2d/TextureAtlas.html" title="class in com.badlogic.gdx.graphics.g2d"><span class="strong">Next Class
</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../../../index.html?com/badlogic/gdx/graphics/g2d/SpriteCache.html" target="_top">Frames
</a></li>
<li><a href="SpriteCache.html" target="_top">No Frames
</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../../allclasses-noframe.html">All Classes
</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
</div>
<div>
<ul class="subNavList">
<li>Summary:
</li>
<li>Nested
|
</li>
<li>Field
|
</li>
<li><a href="#constructor_summary">Constr
</a> |
</li>
<li><a href="#method_summary">Method
</a></li>
</ul>
<ul class="subNavList">
<li>Detail:
</li>
<li>Field
|
</li>
<li><a href="#constructor_detail">Constr
</a> |
</li>
<li><a href="#method_detail">Method
</a></li>
</ul>
</div>
<a name="skip-navbar_bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
<p class="legalCopy"><small>
<div style="font-size:9pt"><i>
Copyright
© 2010-2013 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)
</i></div>
</small></p>
</body>
</html>