GlistEngine
Loading...
Searching...
No Matches
gSpriteAnimation.h File Reference
#include <functional>
#include <memory>
#include "gImage.h"
Include dependency graph for gSpriteAnimation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  gAnimationTrigger
 
class  gSpriteAnimation
 

Macros

#define TRIGGER_NONE   nullptr
 
#define TRIGGER_LESS(First, Second)   createTrigger(First, Second, TriggerCondition::LESS)
 
#define TRIGGER_GREATER(First, Second)   createTrigger(First, Second, TriggerCondition::GREATER)
 
#define TRIGGER_LESS_EQUAL(First, Second)   createTrigger(First, Second, TriggerCondition::LESS_EQUAL)
 
#define TRIGGER_GREATER_EQUAL(First, Second)   createTrigger(First, Second, TriggerCondition::GREATER_EQUAL)
 
#define TRIGGER_EQUAL(First, Second)   createTrigger(First, Second, TriggerCondition::EQUAL)
 
#define TRIGGER_FALSE(First, Second)   createTrigger(First, Second, TriggerCondition::FALSE)
 
#define TRIGGER_TRUE(First, Second)   createTrigger(First, Second, TriggerCondition::TRUE)
 

Enumerations

enum  TriggerCondition {
  LESS , GREATER , LESS_EQUAL , GREATER_EQUAL ,
  EQUAL , FALSE , TRUE , MAX_TRIGGER_CONDITIONS
}
 

Functions

gSpriteAnimationcreateSpriteAnim (std::shared_ptr< gAnimationTrigger > animationTrigger)
 
template<typename First , typename Second >
std::shared_ptr< gAnimationTriggercreateTrigger (First *first, Second *second, TriggerCondition cond)
 

Macro Definition Documentation

◆ TRIGGER_EQUAL

#define TRIGGER_EQUAL (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::EQUAL)

◆ TRIGGER_FALSE

#define TRIGGER_FALSE (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::FALSE)

◆ TRIGGER_GREATER

#define TRIGGER_GREATER (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::GREATER)

◆ TRIGGER_GREATER_EQUAL

#define TRIGGER_GREATER_EQUAL (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::GREATER_EQUAL)

◆ TRIGGER_LESS

#define TRIGGER_LESS (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::LESS)

◆ TRIGGER_LESS_EQUAL

#define TRIGGER_LESS_EQUAL (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::LESS_EQUAL)

◆ TRIGGER_NONE

#define TRIGGER_NONE   nullptr

◆ TRIGGER_TRUE

#define TRIGGER_TRUE (   First,
  Second 
)    createTrigger(First, Second, TriggerCondition::TRUE)

Enumeration Type Documentation

◆ TriggerCondition

Enumerator
LESS 
GREATER 
LESS_EQUAL 
GREATER_EQUAL 
EQUAL 
FALSE 
TRUE 
MAX_TRIGGER_CONDITIONS 

Function Documentation

◆ createSpriteAnim()

gSpriteAnimation * createSpriteAnim ( std::shared_ptr< gAnimationTrigger animationTrigger)

This function can be used to create a gSpriteAnimation with a specified animation trigger. The return of this should be kept, then sprites should be added with loadFrame function. Then the pointer should be passed into the game object's gSpriteAnimator via addAnimation function.


Example: (ator is an instance of a gSpriteAnimator)

gSpriteAnimation* anim1 = createSpriteAnim(TRIGGER_LESS(&a, &b)); anim1->loadFrame("characters/mario_walk_1.png"); anim1->loadFrame("characters/mario_walk_2.png"); ... anim1->setFps(3);

gSpriteAnimation* anim2 = createSpriteAnim(TRIGGER_GREATER(&b, &b)); anim2->loadFrame("characters/mario_run_1.png"); anim2->loadFrame("characters/mario_run_2.png"); ... anim2->setFps(1);

ator.addAnimation(0, anim1);

ator.addAnimation(1, anim2);

To create the gAnimationTrigger, simply use createTrigger function with the required parameters.

See also
createTrigger
Parameters
animationTriggerThe shared_ptr reference to the gAnimationTrigger that was created by createTrigger
Returns
Dynamically created gSpriteAnimation's pointer.

◆ createTrigger()

template<typename First , typename Second >
std::shared_ptr< gAnimationTrigger > createTrigger ( First *  first,
Second *  second,
TriggerCondition  cond 
)

When creating a new gAnimationTrigger object, this function MUST be used to create it. And this function should always be used with createSpriteAnim.

Otherwise it creates an ownership problem.

Returns
The gAnimationTrigger object that has been created.