// // IAPCardView.hpp // demo // // Created by Red_mini on 2024/10/25. // #ifndef IAPCardView_hpp #define IAPCardView_hpp #include "ui/UIPageView.h" #include "cocos2d.h" /** IAPCardView 类 : 封装一个左右滑动切换页面的View,每个页面是一个Node,且带有页面总数及当前页面显示圆点 1. sDotCfg为iPhone主屏下方小圆圈配置。定义如下: struct sDotCfg { int sepWidth = 0; //每个小圆圈之间的间距 int yStart = 0; //默认是在viewSize的底部.也可以设置偏移. string highSp = ""; //当前页高亮与普通对应的图片. string normalSp = ""; }; */ class IAPCardView : public Layer{ public: struct sDotCfg{ int sepWidth = 0; int yStart = 0; string hightSp = ""; string normalSp = ""; }; static IAPCardView* create(cocos2d::Size& viewSize, sDotCfg& dotCfg); void addCard(Node* card); void removeCard(int index); private: // 初始化函数 bool _init(Size& viewSize, sDotCfg& dotCfg); private: sDotCfg _dotCfg; Size _viewSize; ui::PageView* _pageView = nullptr; Node* _indicatorNode = nullptr; std::vector _indicators; }; #endif /* IAPCardView_hpp */