|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.particles.ParticleSystem
public class ParticleSystem
A particle syste responsible for maintaining a set of data about individual particles which are created and controlled by assigned emitters. This pseudo chaotic nature hopes to give more organic looking effects
Field Summary | |
---|---|
static int |
BLEND_ADDITIVE
The blending mode for the glowy style |
static int |
BLEND_COMBINE
The blending mode for the normal style |
protected Particle |
dummy
The dummy particle to return should no more particles be available |
protected java.util.ArrayList |
emitters
The list of emittered producing and controlling particles |
protected SGL |
GL
The renderer to use for all GL operations |
protected int |
maxParticlesPerEmitter
The maximum number of particles allows per emitter |
protected java.util.HashMap |
particlesByEmitter
A map from emitter to a the particle pool holding the particles it uses void: this is now sorted by emitters to allow emitter specfic state to be set for each emitter. |
Constructor Summary | |
---|---|
ParticleSystem(Image defaultSprite)
Create a new particle system |
|
ParticleSystem(Image defaultSprite,
int maxParticles)
Create a new particle system |
|
ParticleSystem(java.lang.String defaultSpriteRef)
Create a new particle system |
|
ParticleSystem(java.lang.String defaultSpriteRef,
int maxParticles)
Create a new particle system |
|
ParticleSystem(java.lang.String defaultSpriteRef,
int maxParticles,
Color mask)
Create a new particle system |
Method Summary | |
---|---|
void |
addEmitter(ParticleEmitter emitter)
Add a particle emitter to be used on this system |
protected Particle |
createParticle(ParticleSystem system)
Create a particle specific to this system, override for your own implementations. |
ParticleSystem |
duplicate()
Create a duplicate of this system. |
int |
getBlendingMode()
Get the blending mode in use |
ParticleEmitter |
getEmitter(int index)
Get an emitter a specified index int he list contained within this system |
int |
getEmitterCount()
Get the number of emitters applied to the system |
Particle |
getNewParticle(ParticleEmitter emitter,
float life)
Get a new particle from the system. |
int |
getParticleCount()
Get the number of particles in use in this system |
float |
getPositionX()
Get the x coordiante of the position of the system |
float |
getPositionY()
Get the y coordiante of the position of the system |
boolean |
isVisible()
Check if this system is currently visible, i.e. |
void |
moveAll(ParticleEmitter emitter,
float x,
float y)
Move all the particles owned by the specified emitter |
void |
release(Particle particle)
Release a particle back to the system once it has expired |
void |
releaseAll(ParticleEmitter emitter)
Release all the particles owned by the specified emitter |
void |
removeAllEmitters()
Remove all the emitters from the system |
void |
removeEmitter(ParticleEmitter emitter)
Remove a particle emitter that is currently used in the system |
void |
render()
Render the particles in the system |
void |
render(float x,
float y)
Render the particles in the system |
void |
reset()
Reset the state of the system |
void |
setBlendingMode(int mode)
Set the blending mode for the particles |
void |
setDefaultImageName(java.lang.String ref)
Set the default image name |
void |
setPosition(float x,
float y)
Set the position at which this system should render relative to the current graphics context setup |
static void |
setRelativePath(java.lang.String path)
Set the path from which images should be loaded |
void |
setRemoveCompletedEmitters(boolean remove)
Indicate if completed emitters should be removed |
void |
setUsePoints(boolean usePoints)
Indicate if this engine should use points to render the particles |
void |
setVisible(boolean visible)
Indicate whether the particle system should be visible, i.e. |
void |
update(int delta)
Update the system, request the assigned emitters update the particles |
boolean |
usePoints()
Check if this engine should use points to render the particles |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected SGL GL
public static final int BLEND_ADDITIVE
public static final int BLEND_COMBINE
protected java.util.HashMap particlesByEmitter
protected int maxParticlesPerEmitter
protected java.util.ArrayList emitters
protected Particle dummy
Constructor Detail |
---|
public ParticleSystem(Image defaultSprite)
defaultSprite
- The sprite to render for each particlepublic ParticleSystem(java.lang.String defaultSpriteRef)
defaultSpriteRef
- The sprite to render for each particlepublic ParticleSystem(java.lang.String defaultSpriteRef, int maxParticles)
defaultSpriteRef
- The sprite to render for each particlemaxParticles
- The number of particles available in the systempublic ParticleSystem(java.lang.String defaultSpriteRef, int maxParticles, Color mask)
defaultSpriteRef
- The sprite to render for each particlemaxParticles
- The number of particles available in the systemmask
- The mask used to make the sprite image transparentpublic ParticleSystem(Image defaultSprite, int maxParticles)
defaultSprite
- The sprite to render for each particlemaxParticles
- The number of particles available in the systemMethod Detail |
---|
public static void setRelativePath(java.lang.String path)
path
- The path from which images should be loadedpublic void reset()
public boolean isVisible()
public void setVisible(boolean visible)
visible
- True if the particle system should renderpublic void setRemoveCompletedEmitters(boolean remove)
remove
- True if completed emitters should be removedpublic void setUsePoints(boolean usePoints)
usePoints
- True if points should be used to render the particlespublic boolean usePoints()
public void setDefaultImageName(java.lang.String ref)
ref
- The default image namepublic int getBlendingMode()
BLEND_COMBINE
,
BLEND_ADDITIVE
protected Particle createParticle(ParticleSystem system)
system
- The system owning this particle
public void setBlendingMode(int mode)
mode
- The mode for blending particles togetherpublic int getEmitterCount()
public ParticleEmitter getEmitter(int index)
index
- The index of the emitter to retrieve
public void addEmitter(ParticleEmitter emitter)
emitter
- The emitter to be addedpublic void removeEmitter(ParticleEmitter emitter)
emitter
- The emitter to be removedpublic void removeAllEmitters()
public float getPositionX()
public float getPositionY()
public void setPosition(float x, float y)
x
- The x coordinate at which this system should be centeredy
- The y coordinate at which this system should be centeredpublic void render()
public void render(float x, float y)
x
- The x coordinate to render the particle system at (in the current coordinate space)y
- The y coordinate to render the particle system at (in the current coordiante space)public void update(int delta)
delta
- The amount of time thats passed since last update in millisecondspublic int getParticleCount()
public Particle getNewParticle(ParticleEmitter emitter, float life)
emitter
- The emitter requesting the particlelife
- The time the new particle should live for
public void release(Particle particle)
particle
- The particle to be releasedpublic void releaseAll(ParticleEmitter emitter)
emitter
- The emitter owning the particles that should be releasedpublic void moveAll(ParticleEmitter emitter, float x, float y)
emitter
- The emitter owning the particles that should be releasedx
- The amount on the x axis to move the particlesy
- The amount on the y axis to move the particlespublic ParticleSystem duplicate() throws SlickException
SlickException
- Indicates a failure during copy or a invalid particle system to be duplicated
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |