Microsoft.Xna.Framework.Graphics
Class SpriteBatch

java.lang.Object
  extended by Microsoft.Xna.Framework.Graphics.GraphicsResource
      extended by Microsoft.Xna.Framework.Graphics.SpriteBatch
All Implemented Interfaces:
IDisposable

public class SpriteBatch
extends GraphicsResource

Enables a group of Sprites to be drawn using the same settings.

Author:
Halofreak1990

Field Summary
 java.lang.String Name
           
 java.lang.Object Tag
           
 
Fields inherited from class Microsoft.Xna.Framework.Graphics.GraphicsResource
_parent, Disposing
 
Constructor Summary
SpriteBatch(GraphicsDevice graphics)
           
 
Method Summary
 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.
 void Dispose()
          Immediately releases the unmanaged resources used by this Object.
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()
           
 boolean IsDisposed()
          Gets a value that indicates whether the object is disposed.
 
Methods inherited from class Microsoft.Xna.Framework.Graphics.GraphicsResource
GraphicsDevice, raise_disposing, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Name

public java.lang.String Name

Tag

public java.lang.Object Tag
Constructor Detail

SpriteBatch

public SpriteBatch(GraphicsDevice graphics)
Parameters:
graphics -
Method Detail

finalize

protected void finalize()
Description copied from class: GraphicsResource
Allows this Object to attempt to free resources and perform other cleanup operations before garbage collection reclaims the object.

Overrides:
finalize in class GraphicsResource

getGraphicsDevice

public GraphicsDevice getGraphicsDevice()

IsDisposed

public boolean IsDisposed()
Description copied from class: GraphicsResource
Gets a value that indicates whether the object is disposed.

Overrides:
IsDisposed in class GraphicsResource

Begin

public void Begin()
Begins a sprite batch operation using deferred sort and default state objects (BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise).


Begin

public 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). If you pass a null blend state, the default is BlendState.AlphaBlend.

Parameters:
sortMode - Sprite drawing order.
blendState - Blending options.

Begin

public 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. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise).

Parameters:
sortMode - Sprite drawing order.
blendState - Blending options.
samplerState - Texture sampling options.
depthStencilState - Depth and stencil options.
rasterizerState - Rasterization options.

Begin

public 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. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default SpriteBatch Class shader.

Parameters:
sortMode - Sprite drawing order.
blendState - Blending options.
samplerState - Texture sampling options.
depthStencilState - Depth and stencil options.
rasterizerState - Rasterization options.
effect - Effect state options.

Begin

public 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. Passing null for any of the state objects selects the default default state objects (BlendState.AlphaBlend, DepthStencilState.None, RasterizerState.CullCounterClockwise, SamplerState.LinearClamp). Passing a null effect selects the default SpriteBatch Class shader.

Parameters:
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.

Dispose

public void Dispose()
Description copied from class: GraphicsResource
Immediately releases the unmanaged resources used by this Object.

Specified by:
Dispose in interface IDisposable
Overrides:
Dispose in class GraphicsResource

Dispose

protected void Dispose(boolean disposing)
Description copied from class: GraphicsResource
Immediately releases the unmanaged resources used by this Object.

Overrides:
Dispose in class GraphicsResource

Draw

public 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.

Parameters:
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.

Draw

public 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.

Parameters:
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.

Draw

public 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.

Parameters:
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.

Draw

public 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.

Parameters:
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.

Draw

public void Draw(Texture2D texture,
                 Rectangle destinationRectangle,
                 Rectangle sourceRectangle,
                 Color color,
                 float rotation,
                 Vector2 origin,
                 SpriteEffects effects,
                 float layerDepth)
Parameters:
texture -
destinationRectangle -
sourceRectangle -
color -
rotation -
origin -
effects -
layerDepth -

Draw

public void Draw(Texture2D texture,
                 Vector2 position,
                 Rectangle sourceRectangle,
                 Color color,
                 float rotation,
                 Vector2 origin,
                 Vector2 scale,
                 SpriteEffects effects,
                 float layerDepth)

Draw

public 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.

Parameters:
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.

DrawString

public 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.

Parameters:
spriteFont - A font for diplaying 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.

DrawString

public 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.

Parameters:
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.

End

public void End()
Flushes the sprite batch and restores the device state to how it was before Begin was called.