Arcade Shooter
Classes | Public Member Functions | List of all members
KatanaEngine::SpriteBatch Class Reference

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

#include <SpriteBatch.h>

Public Member Functions

void Begin (const SpriteSortMode sortMode=SpriteSortMode::DEFERRED, const BlendState blendState=BlendState::ALPHA, ALLEGRO_TRANSFORM *pTransformation=NULL)
 Begins a sprite batch operation. More...
 
void End ()
 Flushes the sprite batch and restores the device state to how it was before Begin was called.
 
void DrawString (const Font *pFont, std::string *text, const Vector2 position, const Color color=Color::White, const TextAlign alignment=TextAlign::LEFT, const float drawDepth=0)
 Adds a string to a batch of sprites to be rendered. More...
 
void Draw (const Texture *pTexture, const Vector2 position, const Region region, const Color color=Color::White, const Vector2 origin=Vector2::Zero, const Vector2 scale=Vector2::One, const float rotation=0, const float drawDepth=0)
 Adds a sprite to a batch of sprites to be rendered. More...
 
void Draw (const Texture *pTexture, const Vector2 position, const Color color=Color::White, const Vector2 origin=Vector2::Zero, const Vector2 scale=Vector2::One, const float rotation=0, const float drawDepth=0)
 Adds a sprite to a batch of sprites to be rendered. More...
 
void Draw (Animation *pAnimation, const Vector2 position, const Color color=Color::White, const Vector2 origin=Vector2::Zero, const Vector2 scale=Vector2::One, const float rotation=0, float drawDepth=0)
 Adds a sprite to a batch of sprites to be rendered. More...
 
void GetBatchSettings (SpriteSortMode &sortMode, BlendState &blendState, ALLEGRO_TRANSFORM *pTransformation)
 Gets the current settings from the sprite batch. More...
 

Detailed Description

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

Member Function Documentation

◆ Begin()

void KatanaEngine::SpriteBatch::Begin ( const SpriteSortMode  sortMode = SpriteSortMode::DEFERRED,
const BlendState  blendState = BlendState::ALPHA,
ALLEGRO_TRANSFORM *  pTransformation = NULL 
)

Begins a sprite batch operation.

Parameters
sortModeDefines how to sort the sprites for rendering.
blendStateDefines how to blend overlaping sprites.
pTransformationDefines a screen space transformation to use.

◆ Draw() [1/3]

void KatanaEngine::SpriteBatch::Draw ( const Texture pTexture,
const Vector2  position,
const Region  region,
const Color  color = Color::White,
const Vector2  origin = Vector2::Zero,
const Vector2  scale = Vector2::One,
const float  rotation = 0,
const float  drawDepth = 0 
)

Adds a sprite to a batch of sprites to be rendered.

Parameters
pTextureA pointer to the texture to render.
positionThe screen position of the sprite.
regionThe region of the texture to render.
colorThe color to tint the sprite. The default is Color::White (no tint).
originThe sprite's origin. The default is Vector2::Zero, which is the upper left corner of the sprite.
scaleThe scale factor of the sprite. The default is Vector2::One.
rotationThe rotation angle in radians. The default is zero.
drawDepthThe depth at which to render the sprite. This is determined by the SpriteSortMode arguement that is passed to SpriteBatch::Begin(). The default is zero.

◆ Draw() [2/3]

void KatanaEngine::SpriteBatch::Draw ( const Texture pTexture,
const Vector2  position,
const Color  color = Color::White,
const Vector2  origin = Vector2::Zero,
const Vector2  scale = Vector2::One,
const float  rotation = 0,
const float  drawDepth = 0 
)

Adds a sprite to a batch of sprites to be rendered.

Parameters
pTextureA pointer to the texture to render.
positionThe screen position of the sprite.
colorThe color to tint the sprite. The default is Color::White (no tint).
originThe sprite's origin. The default is Vector2::Zero, which is the upper left corner of the sprite.
scaleThe scale factor of the sprite. The default is Vector2::One.
rotationThe rotation angle in radians. The default is zero.
drawDepthThe depth at which to render the sprite. This is determined by the SpriteSortMode arguement that is passed to SpriteBatch::Begin(). The default is zero.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ Draw() [3/3]

void KatanaEngine::SpriteBatch::Draw ( Animation pAnimation,
const Vector2  position,
const Color  color = Color::White,
const Vector2  origin = Vector2::Zero,
const Vector2  scale = Vector2::One,
const float  rotation = 0,
float  drawDepth = 0 
)

Adds a sprite to a batch of sprites to be rendered.

Parameters
pAnimationA pointer to the animation to render.
positionThe screen position of the sprite.
colorThe color to tint the sprite. The default is Color::White (no tint).
originThe sprite's origin. The default is Vector2::Zero, which is the upper left corner of the sprite.
scaleThe scale factor of the sprite. The default is Vector2::One.
rotationThe rotation angle in radians. The default is zero.
drawDepthThe depth at which to render the sprite. This is determined by the SpriteSortMode arguement that is passed to SpriteBatch::Begin(). The default is zero.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ DrawString()

void KatanaEngine::SpriteBatch::DrawString ( const Font pFont,
std::string *  text,
const Vector2  position,
const Color  color = Color::White,
const TextAlign  alignment = TextAlign::LEFT,
const float  drawDepth = 0 
)

Adds a string to a batch of sprites to be rendered.

Parameters
pFontThe font used to draw the text.
textThe text to display.
positionThe screen position of the text.
colorThe color to tint the text. The default is Color::White (no tint).
alignmentThe prefered method of aligning the text. The default is TextAlign::LEFT.
drawDepthThe depth at which to render the sprite. This is determined by the SpriteSortMode arguement that is passed to SpriteBatch::Begin(). The default is zero.

◆ GetBatchSettings()

void KatanaEngine::SpriteBatch::GetBatchSettings ( SpriteSortMode sortMode,
BlendState blendState,
ALLEGRO_TRANSFORM *  pTransformation 
)

Gets the current settings from the sprite batch.

Parameters
sortModeDefines how to sort the sprites for rendering.
blendStateDefines how to blend overlaping sprites.
pTransformationDefines a screen space transformation to use.

The documentation for this class was generated from the following files: