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 "cocoa/CCObject.h"
7 #include <string>
8 #include <vector>
9 
10 namespace cocos2d
11 {
12  class CCDictionary;
13  class CCArray;
14 }
15 using namespace cocos2d;
16 
17 class GAFTextureAtlas;
18 class GAFAnimatedObject;
20 
21 class GAFAsset : public CCObject
22 {
23 public:
25  static GAFAsset * create(const std::string& jsonPath);
26  bool initWithImageData(const std::string& jsonPath);
27  GAFAsset();
28  ~GAFAsset();
30  int animationFramesCount() const;
31  GAFTextureAtlas * textureAtlas();
33  CCDictionary * objects();
35  CCDictionary * masks();
37  CCDictionary * namedParts();
39  CCDictionary * animationSequences();
41  GAFAnimationSequence * getSequence(const char * name);
43  CCDictionary* getSequences() const;
45  GAFAnimationSequence * getSequenceByLastFrame(int frame);
47  CCArray * animationFrames();
48  static bool isAssetVersionPlayable(const char * version);
49 
50  GAFAnimatedObject * createObject();
51  GAFAnimatedObject * createObjectAndRun(bool looped = false);
52 
54  static int desiredCsf();
56  static void setDesiredCsf(int csf);
58  inline float usedAtlasContentScaleFactor()const
59  {
60  return _usedAtlasContentScaleFactor;
61  }
62 private:
63  void loadAnimationSequences(CCArray * aSequencesNodes);
64  void loadFramesFromConfigDictionary(CCDictionary * aConfigDictionary);
65  CCArray * objectStatesFromConfigFrame(CCDictionary * configFrame);
66 
67 private:
68  float _usedAtlasContentScaleFactor;
69  float atlasScaleFromAtlasConfig(CCDictionary * anAtlasConfigDictionary);
70  int _majorVersion;
71  int _minorVersion;
72  GAFTextureAtlas * _textureAtlas;
73  // dictionary of objects [ObjectId -> AtlasElementName]
74  CCDictionary * _objects;
75  // dictionary of masks [MaskId -> AtlasElementName]
76  CCDictionary * _masks;
78  CCArray * _interactionObjects;
80  CCArray * _standObjects;
81 
83  CCArray * _animationFrames;
84  CCDictionary * _animationSequences;
85 
86  CCDictionary * _namedParts;
87 };
88 
89 
90 #endif // __GAF_ASSET_H__
Definition: GAFAnimatedObject.h:62
float usedAtlasContentScaleFactor() const
used content scale factor
Definition: GAFAsset.h:58
Definition: GAFAnimationSequence.h:11
Definition: GAFAsset.h:21
Definition: GAFTextureAtlas.h:17