GlistEngine
Loading...
Searching...
No Matches
gSpriteAnimator Class Reference

#include <gSpriteAnimator.h>

Inheritance diagram for gSpriteAnimator:
Collaboration diagram for gSpriteAnimator:

Public Member Functions

 gSpriteAnimator ()
 
virtual ~gSpriteAnimator ()
 
void addAnimation (int animationId, gSpriteAnimation *animation)
 
void changeAnimation (int animationId)
 
void setFps (int animationId, int fps)
 
void update ()
 
void draw (int x, int y)
 
void draw (int x, int y, int w, int h)
 
- Public Member Functions inherited from gObject
 gObject ()
 
void logi (std::string message)
 
void logd (std::string message)
 
void logw (std::string message)
 
void loge (std::string message)
 
void logi (std::string tag, std::string message)
 
void logd (std::string tag, std::string message)
 
void logw (std::string tag, std::string message)
 
void loge (std::string tag, std::string message)
 

Additional Inherited Members

- Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
 
static std::string gGetAssetsDir ()
 
static void gSetAssetsDir (std::string assetsDir)
 
static std::string gGetFilesDir ()
 
static std::string gGetImagesDir ()
 
static std::string gGetFontsDir ()
 
static std::string gGetModelsDir ()
 
static std::string gGetTexturesDir ()
 
static std::string gGetShadersDir ()
 
static std::string gGetSoundsDir ()
 
static std::string gGetDatabasesDir ()
 
static std::string gGetVideosDir ()
 
static void setCurrentResolution (int scalingNo, int currentResolutionNo)
 
- Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
 
static const int LOGLEVEL_DEBUG
 
static const int LOGLEVEL_INFO
 
static const int LOGLEVEL_WARNING
 
static const int LOGLEVEL_ERROR
 
- Static Protected Attributes inherited from gObject
static int renderpassnum
 
static int renderpassno
 
static int releasescaling
 
static int releaseresolution
 

Detailed Description

An instance of this class should be created for each object that is to be animated inside the game. For example; if the developer has a character, an enemy and a door, three instances of this class should be created. Then, the object's individual animations should be added to this class by calling addAnimation.

See also
gSpriteAnimator::addAnimation(int, gSpriteAnimation*)
createSpriteAnim()

Constructor & Destructor Documentation

◆ gSpriteAnimator()

gSpriteAnimator::gSpriteAnimator ( )

◆ ~gSpriteAnimator()

virtual gSpriteAnimator::~gSpriteAnimator ( )
virtual

Member Function Documentation

◆ addAnimation()

void gSpriteAnimator::addAnimation ( int  animationId,
gSpriteAnimation animation 
)

The first argument is just an arbitrary number that is used assigned to the animation passed as the second argument. It can be used with the changeAnimation function to change into playing another animation.

Second argument should always be created with createSpriteAnim function.

Parameters
animationIdThe id that will be given to the animation that's being passed in.
animationThe animation object

◆ changeAnimation()

void gSpriteAnimator::changeAnimation ( int  animationId)

Changes the current playing animation to the specified animation. The animationId should be the id that was assigned to the gSpriteAnimation object passed in when calling addAnimation.

Parameters
animationIdThe animation id that was assigned to the gSpriteAnimation object.

◆ draw() [1/2]

void gSpriteAnimator::draw ( int  x,
int  y 
)

The two parameter draw function.

Call this function inside the draw function of the related Canvas. This draws the current animation on to the x and y coordinates of the screen.

Parameters
xThe x coordinate for the sprite.
yThe y coordinate for the sprite.

◆ draw() [2/2]

void gSpriteAnimator::draw ( int  x,
int  y,
int  w,
int  h 
)

The two parameter draw function.

Call this function inside the draw function of the related Canvas. This draws the current animation on to the x and y coordinates of the screen and scales it by w and h.

Parameters
xThe x coordinate for the sprite.
yThe y coordinate for the sprite.
wThe scaling on the x axis.
hThe scaling on the h axis.

◆ setFps()

void gSpriteAnimator::setFps ( int  animationId,
int  fps 
)

Sets the fps of the given animation.

Parameters
animationIdThe animation id that was assigned to the gSpriteAnimation object.

◆ update()

void gSpriteAnimator::update ( )

Call this update inside the related Canvas's update function.


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