Resolution independent 2D graphics engine
qr::sprite

Class Description

Sprites are objects which store a sequence of images that form an animation. They can be displayed in the scene by attaching them to a scene nodes. The sprites animation frame which is displayed is controlled by the scene node the sprite is attached to.

Public Methods

sprite (scene_manager *scene_man, int num_frames)
void frame_from_raw (char *raw_data, vector2d_i size, int frame)
void create_solid_frame (unsigned char R, unsigned char G, unsigned char B, unsigned char A, unsigned int frame)
void frame_from_bw (char *img_1, int frame_size)
void load_png_frame (const char *name, int frame)
int convert_data ()
void drop ()
char * get_frame_data (int frame)
unsigned int get_total_frames ()
vector2d_i get_frame_size ()

Details

qr::sprite::sprite ( scene_manager * scene_man,
int num_frames
)

Description

Creates a new sprite.

Paramiters

scene_man Resource manager from the renderer.
num_frames Total number of frames that the sprite will store.
void qr::sprite::frame_from_raw ( char * raw_data,
vector2d_i size,
int frame
)

Description

Creates a frame from a block of raw image data.

Paramiters

raw_data Raw image data.
size Image size.
frame Frame number.
void qr::sprite::create_solid_frame ( unsigned char R,
unsigned char G,
unsigned char B,
unsigned char A,
unsigned int frame
)

Description

Creates a solid colour frame.

Paramiters

R Red component.
G Green component.
B Blue component.
A Alpha(transparency) component.
frame Frame number.
void qr::sprite::frame_from_bw ( char * img_1,
int frame_size
)

Description

Create a frame frame from a grey scale image.

Paramiters

img_1 Image data.
frame_size Power of 2 frame size.
void qr::sprite::load_png_frame ( const char * name,
int frame
)

Description

Creates a frame from a PNG image.

Paramiters

name File path.
frame Frame number.
int qr::sprite::convert_data ( )

Description

Loads the image data into the graphics card. Warning, once this method has been called the sprite is no longer editable!.

void qr::sprite::drop ( )

Description

Deletes the sprite.

char* qr::sprite::get_frame_data ( int frame
) [inline]

Description

Gets the image data from a frame of an unconverted sprite.

Paramiters

frame Frame number.
unsigned int qr::sprite::get_total_frames ( ) [inline]

Description

Gets the total number of frames that the sprite can store.

vector2d_i qr::sprite::get_frame_size ( ) [inline]

Description

Gets the size of the frames.