public class SpriteBatch extends GraphicsResource
Modifier and Type | Field and Description |
---|---|
java.lang.String |
Name |
java.lang.Object |
Tag |
_parent, Disposing
Constructor and Description |
---|
SpriteBatch(GraphicsDevice graphics) |
Modifier and Type | Method and Description |
---|---|
void |
Begin()
Begins a sprite batch operation using deferred sort and default state objects (BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise).
|
void |
Begin(SpriteSortMode sortMode,
BlendState blendState)
Begins a sprite batch operation using the specified sort and blend state object and default state objects (DepthStencilState.None, SamplerState.LinearClamp, RasterizerState.CullCounterClockwise).
|
void |
Begin(SpriteSortMode sortMode,
BlendState blendState,
SamplerState samplerState,
DepthStencilState depthStencilState,
RasterizerState rasterizerState)
Begins a sprite batch operation using the specified sort, blend, sampler, depth stencil and rasterizer state objects.
|
void |
Begin(SpriteSortMode sortMode,
BlendState blendState,
SamplerState samplerState,
DepthStencilState depthStencilState,
RasterizerState rasterizerState,
Effect effect)
Begins a sprite batch operation using the specified sort, blend, sampler, depth stencil and rasterizer state objects, plus a custom effect.
|
void |
Begin(SpriteSortMode sortMode,
BlendState blendState,
SamplerState samplerState,
DepthStencilState depthStencilState,
RasterizerState rasterizerState,
Effect effect,
Matrix transformMatrix)
Begins a sprite batch operation using the specified sort, blend, sampler, depth stencil, rasterizer state objects, plus a custom effect and a 2D transformation matrix.
|
protected void |
Dispose(boolean disposing)
Immediately releases the unmanaged resources used by this Object.
|
void |
Draw(Texture2D texture,
Rectangle destinationRectangle,
Color color)
Adds a sprite to a batch of sprites for rendering using the specified texture, destination rectangle, and color.
|
void |
Draw(Texture2D texture,
Rectangle destinationRectangle,
Rectangle sourceRectangle,
Color color)
Adds a sprite to a batch of sprites for rendering using the specified texture, destination rectangle, source rectangle, and color.
|
void |
Draw(Texture2D texture,
Rectangle destinationRectangle,
Rectangle sourceRectangle,
Color color,
float rotation,
Vector2 origin,
SpriteEffects effects,
float layerDepth) |
void |
Draw(Texture2D texture,
Vector2 position,
Color color)
Adds a sprite to a batch of sprites for rendering using the specified texture, position and color.
|
void |
Draw(Texture2D texture,
Vector2 position,
Rectangle sourceRectangle,
Color color)
Adds a sprite to a batch of sprites for rendering using the specified texture, position, source rectangle, and color.
|
void |
Draw(Texture2D texture,
Vector2 position,
Rectangle sourceRectangle,
Color color,
float rotation,
Vector2 origin,
float scale,
SpriteEffects effects,
float layerDepth)
Adds a sprite to a batch of sprites for rendering using the specified texture, destination rectangle, source rectangle, color, rotation, origin, effects and layer.
|
void |
Draw(Texture2D texture,
Vector2 position,
Rectangle sourceRectangle,
Color color,
float rotation,
Vector2 origin,
Vector2 scale,
SpriteEffects effects,
float layerDepth) |
void |
DrawString(SpriteFont spriteFont,
java.lang.String text,
Vector2 position,
Color color)
Adds a string to a batch of sprites for rendering using the specified font, text, position, and color.
|
void |
DrawString(SpriteFont spriteFont,
java.lang.String text,
Vector2 position,
Color color,
float rotation,
Vector2 origin,
float scale,
SpriteEffects effects,
float layerDepth)
Adds a string to a batch of sprites for rendering using the specified font, text, position, color, rotation, origin, scale, effects and layer.
|
void |
End()
Flushes the sprite batch and restores the device state to how it was before Begin was called.
|
protected void |
finalize()
Allows this Object to attempt to free resources and perform other cleanup operations before garbage collection reclaims the object.
|
GraphicsDevice |
getGraphicsDevice()
Gets the GraphicsDevice associated with this GraphicsResource.
|
boolean |
IsDisposed()
Gets a value that indicates whether the object is disposed.
|
Dispose, raise_disposing, toString
public SpriteBatch(GraphicsDevice graphics)
graphics
- ArgumentNullException
- graphics is null.protected void finalize()
GraphicsResource
finalize
in class GraphicsResource
public GraphicsDevice getGraphicsDevice()
GraphicsResource
getGraphicsDevice
in class GraphicsResource
public boolean IsDisposed()
GraphicsResource
IsDisposed
in class GraphicsResource
public void Begin()
public void Begin(SpriteSortMode sortMode, BlendState blendState)
sortMode
- Sprite drawing order.blendState
- Blending options.public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState)
sortMode
- Sprite drawing order.blendState
- Blending options.samplerState
- Texture sampling options.depthStencilState
- Depth and stencil options.rasterizerState
- Rasterization options.public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect)
sortMode
- Sprite drawing order.blendState
- Blending options.samplerState
- Texture sampling options.depthStencilState
- Depth and stencil options.rasterizerState
- Rasterization options.effect
- Effect state options.public void Begin(SpriteSortMode sortMode, BlendState blendState, SamplerState samplerState, DepthStencilState depthStencilState, RasterizerState rasterizerState, Effect effect, Matrix transformMatrix)
sortMode
- Sprite drawing order.blendState
- Blending options.samplerState
- Texture sampling options.depthStencilState
- Depth and stencil options.rasterizerState
- Rasterization options.effect
- Effect state options.transformMatrix
- Transformation matrix for scale, rotate, translate options.protected void Dispose(boolean disposing)
GraphicsResource
Dispose
in class GraphicsResource
public void Draw(Texture2D texture, Rectangle destinationRectangle, Color color)
texture
- A texture.destinationRectangle
- A rectangle that specifies (in screen coordinates) the destination for drawing the sprite.color
- The color to tint a sprite. Use Color.White for full color with no tinting.public void Draw(Texture2D texture, Vector2 position, Color color)
texture
- A texture.position
- The location (in screen coordinates) to draw the sprite.color
- The color to tint a sprite. Use Color.White for full color with no tinting.public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color)
texture
- A texture.destinationRectangle
- A rectangle that specifies (in screen coordinates) the destination for drawing the sprite. If this rectangle is not the same size as the source rectangle, the sprite
will be scaled to fit.sourceRectangle
- A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture.color
- The color to tint a sprite. Use Color.White for full color with no tinting.public void Draw(Texture2D texture, Vector2 position, Rectangle sourceRectangle, Color color)
texture
- A texture.position
- The location (in screen coordinates) to draw the sprite.sourceRectangle
- A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture.color
- The color to tint a sprite. Use Color.White for full color with no tinting.public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth)
texture
- destinationRectangle
- sourceRectangle
- color
- rotation
- origin
- effects
- layerDepth
- public void Draw(Texture2D texture, Vector2 position, Rectangle sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth)
texture
- position
- sourceRectangle
- color
- rotation
- origin
- scale
- effects
- layerDepth
- public void Draw(Texture2D texture, Vector2 position, Rectangle sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
texture
- A texture.position
- The location (in screen coordinates) to draw the sprite.sourceRectangle
- A rectangle that specifies (in texels) the source texels from a texture. Use null to draw the entire texture.color
- The color to tint a sprite. Use Color.White for full color with no tinting.rotation
- Specifies the angle (in radians) to rotate the sprite about its center.origin
- The sprite origin; the default is (0,0) which represents the upper-left corner.scale
- Scale factor.effects
- Effects to apply.layerDepth
- The depth of a layer. By default, 0 represents the front layer and 1 represents a back layer. Use SpriteSortMode if you want sprites to be sorted during drawing.public void DrawString(SpriteFont spriteFont, java.lang.String text, Vector2 position, Color color)
spriteFont
- A font for displaying text.text
- A text string.position
- The location (in screen coordinates) to draw the sprite.color
- The color to tint a sprite. Use Color.White for full color with no tinting.public void DrawString(SpriteFont spriteFont, java.lang.String text, Vector2 position, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth)
spriteFont
- A font for displaying text.text
- A text string.position
- The location (in screen coordinates) to draw the sprite.color
- The color to tint a sprite. Use Color.White for full color with no tinting.rotation
- Specifies the angle (in radians) to rotate the sprite about its center.origin
- The sprite origin; the default is (0,0) which represents the upper-left corner.scale
- Scale factor.effects
- Effects to apply.layerDepth
- The depth of a layer. By default, 0 represents the front layer and 1 represents a back layer. Use SpriteSortMode if you want sprites to be sorted during drawing.public void End()