SpriteManager Class Reference

An improved sprite manager that holds a large wad of surfaces and controls simple PropaneActors by invoking their draw method with the correct data. Originally from Freezer 2. More...

#include <SpriteManager.h>

List of all members.

Public Member Functions

int addSprite (char *filename)
 Loads a sprite from disk.
void freeSprites ()
 Frees all textures.
void drawSprite (int num, int x, int y, int width, int height, float rotation=0.0f)
 Draw a given sprite at a given location (in pixels) [2D Only].
void setScreenSize (int w, int h)
 Sets the screen culling size (in pixels) [2D Only].
int getScreenWidth ()
 Returns the width of the screen culling size [2D only].
int getScreenHeight ()
 Returns the height of the screen culling size [2D only].
int size ()
 Returns the count of sprites contained within.
GLuint * getSprite (int num)
 Returns a texture handle.
 SpriteManager (char *dir)
 Constructor.
 ~SpriteManager ()
 Destructor.


Detailed Description

An improved sprite manager that holds a large wad of surfaces and controls simple PropaneActors by invoking their draw method with the correct data. Originally from Freezer 2.


Constructor & Destructor Documentation

SpriteManager::SpriteManager char *  dir  ) 
 

Constructor.

Create a new SpriteManager based on the sequentially numbered contents of a directory dir.

Files should be named [0..n].png, with no gaps.

Parameters:
dir The directory (e.g. data/sprites)


Member Function Documentation

int SpriteManager::addSprite char *  filename  ) 
 

Loads a sprite from disk.

Add a sprite from filename and return the ID that will be used from now on.

Parameters:
filename The filename for the sprite image (e.g. data/sprites/foobar.tga)
Returns:
The ID that is associated with this texture, or -1 if there was an error.

void SpriteManager::drawSprite int  spriteNum,
int  targetX,
int  targetY,
int  width,
int  height,
float  rotation = 0.0f
 

Draw a given sprite at a given location (in pixels) [2D Only].

Draws a given sprite with details

Set both targetX and targetY to -1337 to draw the sprite at dead centre of the screen (requires you have called SpriteManager::setScreenSize)

Parameters:
spriteNum the internal ID of the sprite to draw.
targetX the X-location in world coordinates to draw the sprite at
targetY the Y-location in world coordinates to draw the sprite at
width The width of the sprite, in pixels
height The height of the sprite, in pixels
rotation The degree of rotation of the sprite, in degrees

void SpriteManager::freeSprites  ) 
 

Frees all textures.

Tells the SpriteManager to dump all textures that it knows about. After calling this function, all sprite IDs will be invalidated.

int SpriteManager::getScreenHeight  ) 
 

Returns the height of the screen culling size [2D only].

Returns the height of the screen, as SpriteManager knows it. Set this value with SpriteManager::setScreenSize

Returns:
The screen height, in pixels.

int SpriteManager::getScreenWidth  ) 
 

Returns the width of the screen culling size [2D only].

Returns the width of the screen, as SpriteManager knows it. Set this value with SpriteManager::setScreenSize

Returns:
The screen width in pixels.

GLuint * SpriteManager::getSprite int  num  ) 
 

Returns a texture handle.

Returns the raw texture for a given sprite ID

Parameters:
num The internal ID for the sprite
Returns:
A pointer to the GL texture handle for that texture, or NULL if the internal ID referenced an invalid/missing sprite

void SpriteManager::setScreenSize int  w,
int  h
 

Sets the screen culling size (in pixels) [2D Only].

Set the width and height of the viewport. Doing so automatically enables culling by draw()

Parameters:
w The width of the screen, in pixels
h The height of the screen, in pixels

int SpriteManager::size  ) 
 

Returns the count of sprites contained within.

Return the count of sprites loaded by this Sprite Manager.

Returns:
The number of sprites held by this sprite manager


The documentation for this class was generated from the following files:
Generated on Sun Jan 14 16:49:11 2007 for Propane Injector by  doxygen 1.4.6