Soooo… originally, I was going to base this off of JME’s emitter, however… once I started poking around inside it, I realized that it wasn’t really influencer based.
The ElementEmitter… is!
There are 4 stock Influencers added to the chain by default… these are:
GravityInfluencer
ColorInfluencer
SizeInfluencer
RotationInfluencer
Writing influencers are very simple, as you are doing nothing more than implementing the Influencer interface, altering one or more of the public particle parameters… the rest is taken care of internal to the emitter.
The base Emitter:
Since it is 2D, you can set the width/height of the emitter (such as the screen width and 0 height, or 50x50… etc, etc)
The emitter has 3 basic parameters that influence particles:
- highLife
- lowLife
- force
This defines the variable life of the particle and the initial velocity. Past this, everything is altered using chained influencers.
I committed the package for people to play around with and I’ll be putting together the wiki on how to’s soon.
Basic usage (example 1)
[java]
ElementEmitter emitter1 = new ElementEmitter(screen,new Vector2f(screen.getWidth()/2,screen.getHeight()/2),10,10);
emitter1.setSprite(“Textures/emittersprite.png”, 4, 4, 4);
emitter1.setMaxParticles(60);
emitter1.setParticlesPerSecond(30);
emitter1.setForce(.045f);
emitter1.setHighLife(4f);
emitter1.setLowLife(1f);
((GravityInfluencer)emitter1.getInfluencer(ElementEmitter.InfluencerType.Gravity)).setGravity(new Vector2f(.05f,0.15f));
((RotationInfluencer)emitter1.getInfluencer(ElementEmitter.InfluencerType.Rotation)).setMaxRotationSpeed(3);
((ColorInfluencer)emitter1.getInfluencer(ElementEmitter.InfluencerType.Color)).setEndColor(ColorRGBA.Yellow);
emitter1.startEmitter(guiNode);
[/java]
Basic Usage (Example 2)
[java]
ElementEmitter emitter2 = new ElementEmitter(screen,new Vector2f(screen.getWidth()/2-200,screen.getHeight()/2),2,2);
emitter2.setSprite(“Textures/emittersprite.png”, 4, 4, 4);
emitter2.setMaxParticles(60);
emitter2.setParticlesPerSecond(30);
emitter2.setForce(.15f);
emitter2.setHighLife(4f);
emitter2.setLowLife(1.2f);
((GravityInfluencer)emitter2.getInfluencer(ElementEmitter.InfluencerType.Gravity)).setGravity(new Vector2f(0f,0f));
((RotationInfluencer)emitter2.getInfluencer(ElementEmitter.InfluencerType.Rotation)).setMaxRotationSpeed(.25f);
((ColorInfluencer)emitter2.getInfluencer(ElementEmitter.InfluencerType.Color)).setStartColor(ColorRGBA.Green);
((ColorInfluencer)emitter2.getInfluencer(ElementEmitter.InfluencerType.Color)).setEndColor(ColorRGBA.White);
((SizeInfluencer)emitter2.getInfluencer(ElementEmitter.InfluencerType.Size)).setStartSize(1f);
((SizeInfluencer)emitter2.getInfluencer(ElementEmitter.InfluencerType.Size)).setStartSize(.5f);
emitter2.startEmitter(guiNode);
[/java]
Basic Usage (Example 3)
[java]
ElementEmitter emitter3 = new ElementEmitter(screen,new Vector2f(screen.getWidth()/2,0),screen.getWidth(),0);
emitter3.setSprite(“Textures/emittersprite.png”, 4, 4, 4);
emitter3.setMaxParticles(60);
emitter3.setParticlesPerSecond(50);
emitter3.setForce(.15f);
emitter3.setHighLife(2f);
emitter3.setLowLife(1.6f);
((GravityInfluencer)emitter3.getInfluencer(ElementEmitter.InfluencerType.Gravity)).setGravity(new Vector2f(0f,-2f));
((RotationInfluencer)emitter3.getInfluencer(ElementEmitter.InfluencerType.Rotation)).setMaxRotationSpeed(.75f);
((ColorInfluencer)emitter3.getInfluencer(ElementEmitter.InfluencerType.Color)).setStartColor(ColorRGBA.White);
((ColorInfluencer)emitter3.getInfluencer(ElementEmitter.InfluencerType.Color)).setEndColor(ColorRGBA.Blue);
((SizeInfluencer)emitter3.getInfluencer(ElementEmitter.InfluencerType.Size)).setStartSize(3f);
((SizeInfluencer)emitter3.getInfluencer(ElementEmitter.InfluencerType.Size)).setStartSize(.5f);
emitter3.startEmitter(guiNode);
[/java]
I’ll be adding one more standard influencer soon for transparency.
End of line