GAF Library
Generic Animation Format
 All Classes Functions Pages
GAFAnimation.h
1 #pragma once
2 
3 #ifndef __GAF_ANIMATION__
4 #define __GAF_ANIMATION__
5 
6 #include "cocoa/CCObject.h"
7 #include <string>
8 
9 #define GAF_FIRST_FRAME_INDEX 0
10 
11 class GAFAsset;
12 class GAFAnimatable;
13 
14 namespace cocos2d
15 {
16  class CCDictionary;
17 }
18 
19 using namespace cocos2d;
20 
21 enum AnimSetSequenceHint
22 {
23  ASSH_CONTINUE,
24  ASSH_RESTART
25 };
26 
27 class GAFAnimatedObject;
28 
30 {
31 public:
32  virtual void onFinishSequence(GAFAnimatedObject * object, const std::string& sequenceName) = 0;
33 };
34 
36 {
37 public:
38  ~GAFAnimation();
39  bool init(GAFAsset * anAnimationData);
40 
41  virtual void processAnimation();
42  virtual void start();
43  virtual void pause();
44  virtual void resume();
45  virtual void stop();
46  virtual void step();
48  bool isDone() const;
49  bool isAnimationRunning() const;
50  bool isLooped() const;
51  void setLooped(bool looped);
52  int totalFrameCount() const;
53  int currentFrameIndex() const;
54 
55  bool setFrame(int index);
56 
58  bool gotoAndStop(const char * frameLabel);
59  bool gotoAndStop(int frameNumber);
60 
62  bool gotoAndPlay(const char * frameLabel);
63  bool gotoAndPlay(int frameNumber);
64 
65 
66  int getStartFrame(const char * frameLabel);
67  int getEndFrame(const char * frameLabel);
68 
74 
75  bool playSequence(const char * name, bool looped = false, bool resume = true, AnimSetSequenceHint hint = ASSH_RESTART);
76  void clearSequence();
78  void setSequenceDelegate(GAFSequenceDelegate * delegate);
79  bool hasSequences() const;
80 protected:
81  GAFAnimation();
82 protected:
83  GAFAsset * _asset;
84  int _currentFrameIndex;
85 private:
86  GAFSequenceDelegate * _sequenceDelegate;
87  int _totalFrameCount;
88  int _currentSequenceStart;
89  int _currentSequenceEnd;
90  bool _isRunning;
91  bool _isLooped;
92 };
93 
94 
95 #endif // __GAF_ANIMATION__
Definition: GAFAnimatedObject.h:62
Definition: GAFAsset.h:21
Definition: GAFAnimation.h:29
Definition: GAFAnimation.h:35