geAnimation

From GriffinEngine
Jump to: navigation, search

Usage

Create an animation using sprites.

Notes on copying and state

A single geAnimation object and all of its references share just one state. Reusing the same object in different places will always produce animations that display the same frame in sync. To create individual instances of the same basic animated sequence, each one playing individually, use the copy constructor to clone the original geAnimation object.

Example: anim2 will share a state with anim1

 geAnimation* anim1 = geResourceManager::instance().getAnimation("some_animation");
 geAnimation* anim2 = anim1;  // make a reference
 anim2->Play();               // anim1 will start playing as well

Example: anim2 copied from anim1, now with its own state

 geAnimation* anim1 = geResourceManager::instance().getAnimation("some_animation");
 geAnimation* anim2 = new geAnimation(anim1);  // make a copy
 anim2->Play();                                // anim1 not affected


Inheritance

Base classes

Reference

Constructors

  •  geAnimation( double _spf = 0, bool _loop = true, bool _reverse = false );
  •  geAnimation( geSpriteSheet* ss, double _spf = 0, bool _loop = true, bool _reverse = false );
  •  geAnimation( const geAnimation& original ); // copy constructor

Accessors

  •  double getFPS() const;
  •  void setFPS( double fps );
  •  double getFrameDuration() const;
  •  void setFrameDuration( double _spf );
  •  void setLoop( bool _loop );
  •  bool getLoop() const;
  •  bool getReverse() const;
  •  void setReverse( bool _reverse );
  •  int getFrameCount() const;
  •  double getLength() const;
  •  geSprite* getSprite() const;
  •  float* getTexCoords( float* fv, int corner ) const;
Simply calls getTexCoords() on the active geSprite.

Methods

  •  void Clear();
  •  void Add( geSprite* s );
  •  bool isPlaying() const;
  •  int getID(){ return 0x0314; }

Playback control

  •  void Play();
  •  void Stop();
  •  void GoTo( int _index );
  •  void NextFrame();
  •  void PrevFrame();