Blame view

ios/Runner/Wowgame/Classes/game_food/ProgressSliderNode.h 2.61 KB
cb213901   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
  //
  //  TimeSliderNode.h
  //  WattsenglishToyApp
  //
  //  Created by Katarzyna Kalinowska-Górska on 27/12/2019.
  //
  
  #ifndef ProgressSliderNode_h
  #define ProgressSliderNode_h
  
  #include "cocos2d.h"
  #include "LayoutObject.h"
  #include "TimeIndicatorInterface.h"
  
  using ProgressSliderNodeOrientation = int;
  static constexpr ProgressSliderNodeOrientation ProgressSliderNodeOrientationHorizontal {0};
  static constexpr ProgressSliderNodeOrientation ProgressSliderNodeOrientationVertical {1};
  
  class ProgressSliderNode : public cocos2d::Node, public LayoutObject, public TimeIndicatorInterface
  {
      public:
      
          static ProgressSliderNode* create(const std::string& sliderImageFilePath, const std::string& thumbImageFilePath, float minVal, float maxVal, ProgressSliderNodeOrientation p_orientation);
      
      virtual bool init(const std::string& sliderImageFilePath, const std::string& thumbImageFilePath, float minVal, float maxVal, ProgressSliderNodeOrientation p_orientations);
      
          virtual void loadPropertiesFromJSON(const rapidjson::Value& jsonValue, LayoutViewInterface* scene = NULL, const std::string resFolder = "", const std::string altResFolder = "") override;
          virtual void prepareSize(const rapidjson::Value& jsonValue, float& width, float& height) override;
  
          // ScenarioObject
      
          virtual void setProperty(std::string propertyName, const rapidjson::Value& newValue, ActionParseDelegate* parseDelegate) override;
          virtual void callFunctionByName(std::string methodName, const rapidjson::Value* arguments, ActionParseDelegate* parseDelegate, std::function<void()> callback = [](){}) override;
      
          // slider's own methods
      
      virtual void setProgressFrac(float progressFrac) override;
      virtual void setProgress(float progress) override;
      virtual float currentProgress() { return _currentValue;};
      virtual void startTimeAnimation(float timeDuration) override;
      virtual void pauseTimeAnimation() override;
      virtual void resumeTimeAnimation() override;
      virtual void pause() override { pauseTimeAnimation(); }
      virtual void resume() override { resumeTimeAnimation(); }
      virtual void stopTimeAnimation() override;
      virtual void setContentSize(const cocos2d::Size& contentSize) override;
      
      
  protected:
      cocos2d::Sprite* _sliderSprite;
      cocos2d::Sprite* _thumbSprite;
      
      float _minValue;
      float _maxValue;
      float _currentValue;
      ProgressSliderNodeOrientation m_orientation { ProgressSliderNodeOrientationHorizontal };
      
      virtual void updateProgressUI(float value, bool animated = true);
      void adjustThumbSpritePosition();
  };
  
  #endif /* TimeSliderNode_h */