GAF Library
Generic Animation Format
 All Classes Functions Pages
GAFAsset.h
1 #pragma once
2 
3 #ifndef __GAF_ASSET_H__
4 #define __GAF_ASSET_H__
5 
6 #include "GAFCollections.h"
7 #include "GAFHeader.h"
8 
9 #include "GAFDelegates.h"
10 
11 class GAFTextureAtlas;
12 class GAFAnimatedObject;
14 class GAFAnimationFrame;
15 
16 class GAFLoader;
17 
18 class GAFAsset : public cocos2d::Ref
19 {
20 private:
21  TextureAtlases_t m_textureAtlases;
22  AnimationMasks_t m_animationMasks;
23  AnimationObjects_t m_animationObjects;
24  AnimationFrames_t m_animationFrames;
25  AnimationSequences_t m_animationSequences;
26  NamedParts_t m_namedParts;
27  GAFHeader m_header;
28 
29  GAFTextureAtlas* m_currentTextureAtlas;
30  GAFTextureLoadDelegate* m_textureLoadDelegate;
31 
32  unsigned int m_sceneFps;
33  unsigned int m_sceneWidth;
34  unsigned int m_sceneHeight;
35  cocos2d::Color4B m_sceneColor;
36 
37 private:
38  float _usedAtlasContentScaleFactor;
39  int _majorVersion;
40  int _minorVersion;
41 
42 public:
44 
45  bool initWithGAFFile(const std::string& filePath, GAFTextureLoadDelegate* delegate = NULL);
46 
47  void pushTextureAtlas(GAFTextureAtlas* atlas);
48  void pushAnimationMask(unsigned int objectId, unsigned int elementAtlasIdRef);
49  void pushAnimationObjects(unsigned int objectId, unsigned int elementAtlasIdRef);
50  void pushAnimationFrame(GAFAnimationFrame* frame);
51  void pushAnimationSequence(const std::string nameId, int start, int end);
52  void pushNamedPart(unsigned int objectIdRef, const std::string& name);
53 
54  void setHeader(GAFHeader& h);
55  const GAFHeader& getHeader() const;
56 
57  const AnimationObjects_t& getAnimationObjects() const;
58  const AnimationMasks_t& getAnimationMasks() const;
59  const AnimationFrames_t& getAnimationFrames() const;
60  const NamedParts_t& getNamedParts() const;
61 
63  const AnimationSequences_t& getAnimationSequences() const;
64 
65  static GAFAsset* create(const std::string& gafFilePath, GAFTextureLoadDelegate* delegate = NULL);
66 
67  GAFAsset();
68  ~GAFAsset();
70  int animationFramesCount() const;
71 
72  GAFTextureAtlas * textureAtlas();
73 
75  const GAFAnimationSequence* getSequence(const std::string& name) const;
76 
78  const GAFAnimationSequence* getSequenceByLastFrame(int frame) const;
79 
81  const GAFAnimationSequence* getSequenceByFirstFrame(int frame) const;
83  static bool isAssetVersionPlayable(const char * version);
84 
85  GAFAnimatedObject * createObject();
86  GAFAnimatedObject * createObjectAndRun(bool looped = false);
87 
89  static float desiredCsf();
91  static void setDesiredCsf(float csf);
93  float usedAtlasContentScaleFactor()const;
94 
95  void setTextureLoadDelegate(GAFTextureLoadDelegate* delegate);
96 
97  const unsigned int getSceneFps() const;
98  const unsigned int getSceneWidth() const;
99  const unsigned int getSceneHeight() const;
100  const cocos2d::Color4B& getSceneColor() const;
101  void setSceneFps(unsigned int);
102  void setSceneWidth(unsigned int);
103  void setSceneHeight(unsigned int);
104  void setSceneColor(const cocos2d::Color4B&);
105 };
106 
107 
108 #endif // __GAF_ASSET_H__
Definition: GAFAnimatedObject.h:33
Definition: GAFLoader.h:11
float usedAtlasContentScaleFactor() const
used content scale factor
Definition: GAFAsset.cpp:241
Definition: GAFAnimationSequence.h:6
Definition: GAFAsset.h:18
int animationFramesCount() const
total number of frames in animation
Definition: GAFAsset.cpp:128
static bool isAssetVersionPlayable(const char *version)
List of GAFAnimationFrame objects.
Definition: GAFAsset.cpp:61
Definition: GAFTextureAtlas.h:9
Definition: GAFDelegates.h:20
Definition: GAFHeader.h:3
const GAFAnimationSequence * getSequenceByLastFrame(int frame) const
get GAFAnimationSequence by last frame number in sequence
Definition: GAFAsset.cpp:145
const GAFAnimationSequence * getSequence(const std::string &name) const
get GAFAnimationSequence by name specified in editor
Definition: GAFAsset.cpp:133
Definition: GAFAnimationFrame.h:9
const AnimationSequences_t & getAnimationSequences() const
get all of the sequences
Definition: GAFAsset.cpp:226
bool initWithGAFFile(const std::string &filePath, GAFTextureLoadDelegate *delegate=NULL)
Initializes asset with bGAF data.
Definition: GAFAsset.cpp:78
static void setDesiredCsf(float csf)
sets desired content scale factor
Definition: GAFAsset.cpp:20
const GAFAnimationSequence * getSequenceByFirstFrame(int frame) const
get GAFAnimationSequence by first frame number in sequence
Definition: GAFAsset.cpp:163
static float desiredCsf()
desired content scale factor
Definition: GAFAsset.cpp:15