123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #ifndef __CCPARTICLEBATCHNODE_H__
- #define __CCPARTICLEBATCHNODE_H__
- #include "2d/CCNode.h"
- #include "base/CCProtocols.h"
- #include "renderer/CCBatchCommand.h"
- NS_CC_BEGIN
- class Texture2D;
- class TextureAtlas;
- class ParticleSystem;
- #define kParticleDefaultCapacity 500
- class CC_DLL ParticleBatchNode : public Node, public TextureProtocol
- {
- public:
-
- static ParticleBatchNode* createWithTexture(Texture2D *tex, int capacity = kParticleDefaultCapacity);
-
- static ParticleBatchNode* create(const std::string& fileImage, int capacity = kParticleDefaultCapacity);
-
- void insertChild(ParticleSystem* system, int index);
-
- void removeChildAtIndex(int index, bool doCleanup);
- void removeAllChildrenWithCleanup(bool doCleanup) override;
-
- void disableParticle(int particleIndex);
-
- TextureAtlas* getTextureAtlas() const { return _textureAtlas; }
-
-
- void setTextureAtlas(TextureAtlas* atlas) { _textureAtlas = atlas; }
-
-
- virtual void visit(Renderer *renderer, const Mat4 &parentTransform, uint32_t parentFlags) override;
- using Node::addChild;
- virtual void addChild(Node * child, int zOrder, int tag) override;
- virtual void addChild(Node * child, int zOrder, const std::string &name) override;
- virtual void removeChild(Node* child, bool cleanup) override;
- virtual void reorderChild(Node * child, int zOrder) override;
- virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
- virtual Texture2D* getTexture(void) const override;
- virtual void setTexture(Texture2D *texture) override;
-
- virtual void setBlendFunc(const BlendFunc &blendFunc) override;
-
- virtual const BlendFunc& getBlendFunc(void) const override;
-
- CC_CONSTRUCTOR_ACCESS:
-
- ParticleBatchNode();
-
- virtual ~ParticleBatchNode();
-
-
- bool initWithTexture(Texture2D *tex, int capacity);
-
-
- bool initWithFile(const std::string& fileImage, int capacity);
-
- private:
- void updateAllAtlasIndexes();
- void increaseAtlasCapacityTo(ssize_t quantity);
- int searchNewPositionInChildrenForZ(int z);
- void getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z);
- int addChildHelper(ParticleSystem* child, int z, int aTag, const std::string &name, bool setTag);
- void addChildByTagOrName(ParticleSystem* child, int z, int tag, const std::string &name, bool setTag);
- void updateBlendFunc(void);
-
- TextureAtlas* _textureAtlas;
-
- BlendFunc _blendFunc;
-
- BatchCommand _batchCommand;
- };
- NS_CC_END
- #endif
|