IAPCardView.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // IAPCardView.hpp
  3. // demo
  4. //
  5. // Created by Red_mini on 2024/10/25.
  6. //
  7. #ifndef IAPCardView_hpp
  8. #define IAPCardView_hpp
  9. #include "ui/UIPageView.h"
  10. #include "cocos2d.h"
  11. /**
  12. IAPCardView 类 :
  13. 封装一个左右滑动切换页面的View,每个页面是一个Node,且带有页面总数及当前页面显示圆点
  14. 1. sDotCfg为iPhone主屏下方小圆圈配置。定义如下:
  15. struct sDotCfg {
  16. int sepWidth = 0; //每个小圆圈之间的间距
  17. int yStart = 0; //默认是在viewSize的底部.也可以设置偏移.
  18. string highSp = ""; //当前页高亮与普通对应的图片.
  19. string normalSp = "";
  20. };
  21. */
  22. class IAPCardView : public Layer{
  23. public:
  24. struct sDotCfg{
  25. int sepWidth = 0;
  26. int yStart = 0;
  27. string hightSp = "";
  28. string normalSp = "";
  29. };
  30. static IAPCardView* create(cocos2d::Size& viewSize, sDotCfg& dotCfg);
  31. void addCard(Node* card);
  32. void removeCard(int index);
  33. private:
  34. // 初始化函数
  35. bool _init(Size& viewSize, sDotCfg& dotCfg);
  36. private:
  37. sDotCfg _dotCfg;
  38. Size _viewSize;
  39. ui::PageView* _pageView = nullptr;
  40. Node* _indicatorNode = nullptr;
  41. std::vector<Sprite*> _indicators;
  42. };
  43. #endif /* IAPCardView_hpp */