Blame view

ios/Runner/Wowgame/Classes/game_toy/ToyLayoutObject.h 2.22 KB
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  //
  //  ToyLayoutObject.h
  //  SteveMaggieCpp
  //
  //  Created by Katarzyna Kalinowska-Górska on 16.05.2017.
  //
  //
  
  #ifndef ToyLayoutObject_h
  #define ToyLayoutObject_h
  
  #include "json/document.h"
  #include "ui/CocosGUI.h"
  #include "ToyScenarioObject.h"
  #include "ToyJSONParseUtils.h"
  
  class ToyLayoutViewInterface;
  
  class ToyLayoutObject : public ToyScenarioObject
  {
      public:
      
          std::string className;
          std::string objectName;
          cocos2d::Point originalPosition;
      
          virtual ~ToyLayoutObject();
      
          virtual void loadPropertiesFromJSON(const rapidjson::Value& jsonValue, ToyLayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "") = 0;
      
          virtual void loadCommonPropertiesFromJSON(const rapidjson::Value& jsonValue, ToyLayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "");
      
          virtual void prepareSize(const rapidjson::Value& jsonValue, float& width, float& height);
      
          virtual bool isWidget()
          {
              return false;
          };
      
          // for widgets
      
          virtual void setOnTouchBeganCallback(std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> callback){};
          virtual void setOnTouchEndedCallback(std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> callback){};
          virtual void setOnTouchCancelledCallback(std::function<void(std::string, cocos2d::ui::Widget::TouchEventType)> callback){};
  
          // ToyScenarioObject
          virtual std::string getObjectName(){
              return objectName;
          };
      
          virtual std::string getClassName(){
              return className;
          };
      
          virtual std::string getPropertyAsString(std::string propertyName = ""){
              if(propertyName == "objectName"){
                  return objectName;
              }
              return "NULL";
          };
      
          virtual void animate(){
              if(_activationAnimation != nullptr){
                  animate(_activationAnimation);
              }
          }
      
  protected:
      rapidjson::Value* _activationAnimation;
      
      virtual float animate(rapidjson::Value* animationData);
  };
  
  #endif /* ToyLayoutObject_h */