diff options
author | chai <chaifix@163.com> | 2018-10-29 08:27:51 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-29 08:27:51 +0800 |
commit | aca962d7ce3d404671cace2a82b04ff937375009 (patch) | |
tree | ec315ef9df3dbd971bc914dae689e97cf9cf31ff /src/libjin/Graphics/particles/je_particle_system.h | |
parent | 297c78319e6bd891f27f9546334feedc030fc0a7 (diff) |
*修改代码结构
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle_system.h')
-rw-r--r-- | src/libjin/Graphics/particles/je_particle_system.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src/libjin/Graphics/particles/je_particle_system.h b/src/libjin/Graphics/particles/je_particle_system.h new file mode 100644 index 0000000..aa7ff99 --- /dev/null +++ b/src/libjin/Graphics/particles/je_particle_system.h @@ -0,0 +1,94 @@ +#ifndef __JE_PARTICLE_EMMITTER_H +#define __JE_PARTICLE_EMMITTER_H + +#include <vector> + +#include "../../common/je_temporary.h" +#include "../../game/je_gameobject.h" + +#include "../je_sprite.h" + +#include "je_particle_emitter.h" +#include "je_particle_pool.h" +#include "je_particle.h" + +namespace JinEngine +{ + namespace Graphics + { + namespace Particles + { + + /// + /// Definition of particle system. + /// + struct ParticleSystemDef : public Temporary + { + uint maxParticleCount = 1; ///< Max count of particles in pool. 1 by default. + + ParticleEmitterDef emitterDef; ///< Particle emitter definition. + ParticleDef particleDef; ///< Particle definition. + }; + + /// + /// Particle emitter, handle all particles it emitts. + /// + class ParticleSystem : public Game::GameObject + { + public: + /// + /// Particle system constructor + /// + /// @param def Definition of particle system. + /// + ParticleSystem(const ParticleSystemDef& def); + + /// + /// Particle system destructor. + /// + ~ParticleSystem(); + + /// + /// Render particle system's all particles. + /// + void render(int x, int y, float sx = 1, float sy = 1, float r = 0, float ax = 0, float ay = 0); + + /// + /// Set sprite to render. + /// + /// @param sprite Sprite to render. + /// + void setSprite(Sprite* sprite); + + /// + /// Release particle and make it available in particle pool. + /// + void releaseParticle(); + + private: + // Disable default constructor. + ParticleSystem(); + + /// + /// Sprite to be drawn. + /// + Sprite* mSprite; + + /// + /// Particle emitter. + /// + ParticleEmitter mEmitter; + ParticlePool mParticlePool; + + /// + /// Alive particles, that means these particles could join to the life cycle loop. + /// + std::vector<Particle*> mAliveParticles; + + }; + + } // namespace Particles + } // namespace Graphics +} // namespace JinEngine + +#endif
\ No newline at end of file |