REDBatchNode.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // REDBatchNode.h
  3. // cocos2d_libs
  4. //
  5. // Created by xiao鱼哥 on 2023/2/2.
  6. //
  7. #ifndef REDBatchNode_h
  8. #define REDBatchNode_h
  9. #include "REDReader.h"
  10. #include "REDBatchNodeHeader.h"
  11. NS_CC_BEGIN
  12. class EventDispatcher;
  13. class EventCustom;
  14. class EventListenerCustom;
  15. class Sprite;
  16. NS_CC_END
  17. namespace redream {
  18. class REDBatchNode : public Ref,public REDBatchNodeListener
  19. {
  20. #pragma mark - 预定义一些类型
  21. using string = std::string;
  22. using Node = cocos2d::Node;
  23. using REDPlistPic = std::unordered_map<string,std::vector<string>>;
  24. using VecNode = std::vector<Node*>;
  25. using EventListenerCustom = cocos2d::EventListenerCustom;
  26. using Sprite = cocos2d::Sprite;
  27. #pragma
  28. public:
  29. static REDBatchNode * create();
  30. REDBatchNode();
  31. virtual ~REDBatchNode();
  32. ///设置RootNode和对应的AnimMgr,同时监听以CCBName为key的自定义事件.
  33. void setRootNode(Node* node,REDAnimationManager* animMgr);
  34. ///从Reader中读取的信息赋值到batchNode
  35. void setBatchPlistSpriteNames(REDPlistPic & SpNames);
  36. virtual void onListener()override;
  37. protected:
  38. virtual bool init();
  39. void mergeFinish();
  40. void batchEnd(Node* node);
  41. bool resetNode(Node* node);
  42. bool resetSprite(Sprite* sp);
  43. Node* _rootNode = nullptr;
  44. REDAnimationManager* _animMgr = nullptr;
  45. ///需要合批的 plist图对应的所有的SpriteNames.
  46. REDPlistPic _needBatchPlistSpriteNames;
  47. bool _useCache = false;
  48. EventListenerCustom* _mergeListerner=nullptr;
  49. string _redreamName;
  50. };
  51. }
  52. #endif /* REDBatchNode_h */