Wraith  0.1.5
Basic 3D game engine in C++
SpriteFont Class Reference

A sprite font used for get characters (glyps) from a particular texture. More...

#include <SpriteFont.h>

Collaboration diagram for SpriteFont:
Collaboration graph

Public Types

typedef int Key
 
typedef Sprite Glyph
 

Public Member Functions

 SpriteFont (const SpriteFont &)=delete
 
SpriteFontoperator= (const SpriteFont &)=delete
 
 SpriteFont (SpriteFont &&)=delete
 
SpriteFontoperator= (SpriteFont &&)=delete
 
 SpriteFont (const std::string &filePath)
 Constructor taking in a filePath. More...
 
GlyphgetGlyph (char character) const
 Gets a glyph. More...
 
const std::string & getName () const
 Gets the name of the font More...
 

Private Types

typedef std::map< Key, Glyph * > FontMap
 

Private Member Functions

void parseXMLtoCollection (const std::string &filename)
 Parses XML file. More...
 
void elementTextToInt (IXmlReader *pReader, int &out)
 Converts element text to int. More...
 
SpritecreateSprite (Key, int x, int y, int w, int h)
 Creates a sprite. More...
 
void loadImageIntoImageManager (int x, int y, int w, int h, const std::string &name)
 Loads image into image manager. More...
 

Private Attributes

std::string _name
 
Texture * _pFontTexture
 
FontMap _fontMap
 

Detailed Description

A sprite font used for get characters (glyps) from a particular texture.

SpriteFonts are created and maintained by tge SpriteFontManager.

Constructor & Destructor Documentation

◆ SpriteFont()

SpriteFont::SpriteFont ( const std::string &  filePath)

Constructor taking in a filePath.

Parameters
filePathFull pathname of the file of texture and xml file.

Member Function Documentation

◆ createSprite()

Sprite * SpriteFont::createSprite ( Key  key,
int  x,
int  y,
int  w,
int  h 
)
private

Creates a sprite.

Parameters
parameter1The first parameter.
xThe x coordinate.
yThe y coordinate.
wThe width.
hThe height.
Returns
Null if it fails, else the new sprite.

◆ elementTextToInt()

void SpriteFont::elementTextToInt ( IXmlReader *  pReader,
int &  out 
)
private

Converts element text to int.

Parameters
pReaderthe reader.
out[in,out] The out.

◆ getGlyph()

SpriteFont::Glyph * SpriteFont::getGlyph ( char  character) const

Gets a glyph.

Parameters
characterThe character.
Returns
pointer to a glyph.

◆ getName()

const std::string & SpriteFont::getName ( ) const

Gets the name of the font

Returns
The name.

◆ loadImageIntoImageManager()

void SpriteFont::loadImageIntoImageManager ( int  x,
int  y,
int  w,
int  h,
const std::string &  name 
)
private

Loads image into image manager.

Parameters
xThe x coordinate.
yThe y coordinate.
wThe width.
hThe height.
nameThe name.

◆ parseXMLtoCollection()

void SpriteFont::parseXMLtoCollection ( const std::string &  filename)
private

Parses XML file.

Parameters
filenameFilename of the the XML.

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