LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
AnimatedImage Class Reference

An image that can store and play animation sequences. More...

#include <animatedimage.h>

Inherits Image.

Public Member Functions

 AnimatedImage (const std::string &file)
 
void Update ()
 
void Play (std::string name)
 
std::string Playing ()
 
void Save (const std::string &file) const
 
- Public Member Functions inherited from Image
 Image (const std::string &file)
 
 ~Image ()
 
void SetClips (const std::vector< Recti > &clips)
 
void GenClips (int cW, int cH)
 
SDL_Texture * Texture ()
 
Recti Clip (int clipNum) const
 
Recti Clip () const
 
void SetActiveClip (int clip)
 
int ClipCount () const
 
void Size (int *w, int *h=NULL) const
 
int W () const
 Get the Image texture's width.
 
int H () const
 Get the Image texture's height.
 
std::string File () const
 Get the Image filename.
 
virtual void Load (const std::string &file)
 

Additional Inherited Members

- Protected Member Functions inherited from Image
Json::Value SaveClips () const
 
- Protected Attributes inherited from Image
std::shared_ptr< SDL_Texture > mTexture
 
std::string mFile
 
RectimClips
 
int mNumClips
 
int mActiveClip
 

Detailed Description

An image that can store and play animation sequences.

Used for storing and playing animation sequences, inherits from Image

Constructor & Destructor Documentation

AnimatedImage::AnimatedImage ( const std::string &  file)

Setup the AnimatedImage class, if a filename is passed load the image

Parameters
fileThe filename
See Also
Window::LoadImage for the loading function

Member Function Documentation

void AnimatedImage::Play ( std::string  name)

Play the desired animation

Parameters
nameThe animation name to play
std::string AnimatedImage::Playing ( )

Get the name of the active animation

Returns
The name of the animation currently playing
void AnimatedImage::Save ( const std::string &  file) const
virtual

Save an AniamtedImage's properties to a Json formatted file

Parameters
fileThe file to save to

Reimplemented from Image.

void AnimatedImage::Update ( )

Update the animation, called every frame We check if time greater than the time for one frame (1 / frameRate) and if yes we then increment the frame counter by the # frames elapsed in case the animation frameRate is higher than the game framerate


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