Positioning particles and life span of particle system in AndEngine GLES2

1.1k Views Asked by At

I am using particle system in my game, in andEngine GLES2, to produce a glittering effect.
I could not find a way to position particles after these are attached to the scene(run time).
Secondly i want to know if there is a way to make a check on the particles movement like listener in animations because I want to stop particles to emit after they expire first time.
Any help in this regard will be much appreciated.

2

There are 2 best solutions below

0
On

if you want to move particles in different directions then add

new VelocityParticleInitializer<Sprite>(30,-42, -40, 40)

to the partial system.

Example:

systemBallParticleSystem.addParticleInitializer(new VelocityParticleInitializer<Sprite>(30,-42, -40, 40));

Second point when partical effect started register a delay modifier and detach your system after that time

Example:

registerEntityModifier(new DelayModifier(pDuration, pEntityModifierListener));

in this pEntityModifierListener you can detach your partical system

2
On

First positioning particle system, There is a method setCenter that you can use in following manner.

particleEmitter.setCenter(pSceneTouchEvent.getX(), pSceneTouchEvent.getY());

Also you can see basic andengine example to clear your concept.

Second stop particle system, As per my consideration there is no listener for particle system. So to satisfy you need you have to think differently. You have to use TimerHandler to satisfy your need. When first time onTimer method of TimerHandler gets executed at that time you have to detach particle system or whatever you want to do.