1. Introduction
The particle system represents the technique of simulating some specific fuzzy phenomena in three-dimensional computer graphics, and these phenomena are difficult to achieve with other traditional rendering techniques. Real game physics. Frequently used particle systems to simulate phenomena such as fire, explosion, smoke, water, sparks, leaves, clouds, fog, snow, dust, meteor trails or the like, such as the trajectory of abstract visual effects and so on.
2. Particle system Structure
particles, particle emitters, particle initializers, particle modifiers in the particle system of the OGE engine represent particle effects.
Particle system: is a subclass of entity that manages a system of particle emitters, emission ratios, particle hatching, management of particle modifiers, etc.
Particle emitter: Inherits Iupdatehandler, randomly generates emission coordinates at a fixed range
Particle initializer: Initializes the entity portion of the parameter. such as: Alpha value
Particle modifier: the particle initializer subclass, which also modifies the entity part parameters, but is updated in the onmanagedupdate of the particle system, similar to the effect of registering modifier in entity
Particle: Encapsulates an entity that contains properties of some particles
3. Example code:
public void setmyparticle (float PX, float PY, Textureregion region, Scene pscene) {
Pointparticleemitter particleemitter = new Pointparticleemitter (PX, PY);
Spriteparticlesystem Mparticlesystem = new Spriteparticlesystem (Particleemitter, ten, Ten, Pscene.getvertexbufferobjectmanager ());
Mparticlesystem.addparticleinitializer (New velocityparticleinitializer<sprite> (-150, 150,-380, 0));
Mparticlesystem.addparticleinitializer (New expireparticleinitializer<sprite> (5f, 6f));
Mparticlesystem.addparticlemodifier (New scaleparticlemodifier<sprite> (0f, 5f, 0, 1.3f));
Mparticlesystem.addparticlemodifier (New Alphaparticlemodifier<sprite> (0.8f, 1, 0.2f, 1f));
Pscene.attachchild (Mparticlesystem);
}