123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // ParticleSystemModule.hpp
- // ParticleTool
- //
- // Created by zhuangyou on 2019/5/9.
- //
- #ifndef RUParticleSystemModule_hpp
- #define RUParticleSystemModule_hpp
- #include "cocos2d.h"
- #include "RUDefine.h"
- NS_RU_BEGIN
- enum class SheetMode{
- GRIDE = 0,
- PLIST, //TODO
- };
- enum class SheetAnimationMode{
- WHOLESHEET,
- SINGLEROW,//TODO
- };
- enum class ParticleSystemModuleFlag
- {
- SHAPE = 1<< 0,
- TEXTURE_SHEET = 1<< 1,
- TRAIL = 1<< 2,
- NOISE = 1 << 3,
- };
- class ParticleSystemModule{
-
- public:
-
- ParticleSystemModule(){}
- ~ParticleSystemModule(){}
-
- void setEnable(bool isEnable) { enable = isEnable; onEnable(enable);}
- bool isEnable() { return enable;}
-
- virtual void init(){}
- virtual void onEnable(bool isEnable){}
- virtual void update(){}
-
- void setParticleSystem(ParticleSystem* particleSystem){_particleSystem = particleSystem;}
- ParticleSystem* getParitcleSystem(){return _particleSystem;}
-
- ParticleSystemModuleFlag getFlag(){return _flag;}
-
- protected:
-
- ParticleSystem* _particleSystem;
- bool enable;
- ParticleSystemModuleFlag _flag;
- };
- class TextureSheetAnimationModule :public ParticleSystemModule
- {
- public:
- TextureSheetAnimationModule():_startFrame(0),_frameCount(1),_useRandomStartFrame(false)
- {_mode = SheetMode::GRIDE;_animationMode = SheetAnimationMode::WHOLESHEET;_flag = ParticleSystemModuleFlag::TEXTURE_SHEET;_fileName = "";}
-
- ~TextureSheetAnimationModule(){}
-
- Vec2 getTiles(){ return _tiles;}
- void setTiles(const Vec2 &tiles) { _tiles = Vec2(tiles.x,tiles.y);}
- void setStartFrame(int frame) {_startFrame = frame;}
- int getFrameCount() { return _frameCount; }
- void setFrameCount(int framCount) { _frameCount = framCount; }
- void setUseRandomStartFrame(bool useRnd) { _useRandomStartFrame = useRnd;}
- bool isUseRandomStartFrame() { return _useRandomStartFrame;}
- void setCycles(int cycles) {_cycles = cycles;}
- void setFlipX(int flip) { _flipX = flip;}
- void setFlipY(int flip) { _flipY = flip;}
- void setTexture(Texture2D* texture) { _texture = texture;}
- float getTileWidth() {return _tileWidth;}
- float getTileHeight() {return _tileHeight;}
- SpriteFrame* generateSpriteFrame(int index);
- void setFileName(string fileName) {_fileName = fileName;};
-
- virtual void init(){}
- virtual void onEnable(bool isEnable);
- // virtual void update();
-
-
- private:
- Vec2 _tiles;
-
- int _startFrame;
- int _frameCount;
- int _cycles;
- int _flipX;
- int _flipY;
- float _tileWidth;
- float _tileHeight;
- bool _useRandomStartFrame;
- SheetMode _mode;
- SheetAnimationMode _animationMode;
-
- Texture2D* _texture;
-
- string _fileName;//在大图中的名字
-
- };
- class NoiseModule :public ParticleSystemModule
- {
- public:
-
- NoiseModule(){
- _bCheapGradient = true;//目前可以忽略
- _frequency = 1.0;
- _octaves = 2;
- _lacunarity = 2.0;
- _persistence = 0.5;
-
- _strength = 1.0;
-
- _flag = ParticleSystemModuleFlag::NOISE;
- }
-
- ~NoiseModule(){}
- void setFrequency(float freq) { _frequency = freq;}
- float getFrequency() {return _frequency;}
- void setOctaves(unsigned int oct) {_octaves = oct;}
- int getOctaves() {return _octaves;}
- void setLacunarity(float lac) { _lacunarity = lac;}
- float getLacunarity() {return _lacunarity;}
- void setPersistence(float pers) { _persistence = pers;}
- float getPersistence() {return _persistence;}
-
- void setStrength(float strength){ _strength = strength; }
- float getStrength() {return _strength;}
-
- virtual void init(){}
- virtual void onEnable(bool isEnable);
- // virtual void update();
- private:
-
- private:
- bool _bCheapGradient;
- float _frequency;
- unsigned int _octaves;
- float _lacunarity;
- float _persistence;
-
- float _strength;
-
- };
- NS_RU_END
- #endif /* RUParticleSystemModule_hpp */
|