Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.newdawn.slick.particles
Class ParticleSystem

    java.lang.Object
      org.newdawn.slick.particles.ParticleSystem

    public class ParticleSystem

extends java.lang.Object

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

Author:
  kevin

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

### GL

    protected SGL GL

  The renderer to use for all GL operations

### BLEND_ADDITIVE

    public static final int BLEND_ADDITIVE

  The blending mode for the glowy style

  See Also:
    Constant Field Values

### BLEND_COMBINE

    public static final int BLEND_COMBINE

  The blending mode for the normal style

  See Also:
    Constant Field Values

### particlesByEmitter

    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. actually this is used to allow setting an individual blend mode for each emitter

### maxParticlesPerEmitter

    protected int maxParticlesPerEmitter

  The maximum number of particles allows per emitter

### emitters

    protected java.util.ArrayList emitters

  The list of emittered producing and controlling particles

### dummy

    protected Particle dummy

  The dummy particle to return should no more particles be available

Constructor Detail

### ParticleSystem

    public ParticleSystem(Image defaultSprite)

  Create a new particle system

  Parameters:
    `defaultSprite` - The sprite to render for each particle

### ParticleSystem

    public ParticleSystem(java.lang.String defaultSpriteRef)

  Create a new particle system

  Parameters:
    `defaultSpriteRef` - The sprite to render for each particle

### ParticleSystem

    public ParticleSystem(java.lang.String defaultSpriteRef,
                          int maxParticles)

  Create a new particle system

  Parameters:
    `defaultSpriteRef` - The sprite to render for each particle
    `maxParticles` - The number of particles available in the system

### ParticleSystem

    public ParticleSystem(java.lang.String defaultSpriteRef,
                          int maxParticles,
                          Color mask)

  Create a new particle system

  Parameters:
    `defaultSpriteRef` - The sprite to render for each particle
    `maxParticles` - The number of particles available in the system
    `mask` - The mask used to make the sprite image transparent

### ParticleSystem

    public ParticleSystem(Image defaultSprite,
                          int maxParticles)

  Create a new particle system

  Parameters:
    `defaultSprite` - The sprite to render for each particle
    `maxParticles` - The number of particles available in the system

Method Detail

### setRelativePath

    public static void setRelativePath(java.lang.String path)

  Set the path from which images should be loaded

  Parameters:
    `path` - The path from which images should be loaded

### reset

    public void reset()

  Reset the state of the system

### isVisible

    public boolean isVisible()

  Check if this system is currently visible, i.e. it's actually rendered

  Returns:
    True if the particle system is rendered

### setVisible

    public void setVisible(boolean visible)

  Indicate whether the particle system should be visible, i.e. whether it'll actually render

  Parameters:
    `visible` - True if the particle system should render

### setRemoveCompletedEmitters

    public void setRemoveCompletedEmitters(boolean remove)

  Indicate if completed emitters should be removed

  Parameters:
    `remove` - True if completed emitters should be removed

### setUsePoints

    public void setUsePoints(boolean usePoints)

  Indicate if this engine should use points to render the particles

  Parameters:
    `usePoints` - True if points should be used to render the particles

### usePoints

    public boolean usePoints()

  Check if this engine should use points to render the particles

  Returns:
    True if the engine should use points to render the particles

### setDefaultImageName

    public void setDefaultImageName(java.lang.String ref)

  Set the default image name

  Parameters:
    `ref` - The default image name

### getBlendingMode

    public int getBlendingMode()

  Get the blending mode in use

  Returns:
    The blending mode in use
  See Also:
    `BLEND_COMBINE`, `BLEND_ADDITIVE`

### createParticle

    protected Particle createParticle(ParticleSystem system)

  Create a particle specific to this system, override for your own implementations. These particles will be cached and reused within this system.

  Parameters:
    `system` - The system owning this particle
  Returns:
    The newly created particle.

### setBlendingMode

    public void setBlendingMode(int mode)

  Set the blending mode for the particles

  Parameters:
    `mode` - The mode for blending particles together

### getEmitterCount

    public int getEmitterCount()

  Get the number of emitters applied to the system

  Returns:
    The number of emitters applied to the system

### getEmitter

    public ParticleEmitter getEmitter(int index)

  Get an emitter a specified index int he list contained within this system

  Parameters:
    `index` - The index of the emitter to retrieve
  Returns:
    The particle emitter

### addEmitter

    public void addEmitter(ParticleEmitter emitter)

  Add a particle emitter to be used on this system

  Parameters:
    `emitter` - The emitter to be added

### removeEmitter

    public void removeEmitter(ParticleEmitter emitter)

  Remove a particle emitter that is currently used in the system

  Parameters:
    `emitter` - The emitter to be removed

### removeAllEmitters

    public void removeAllEmitters()

  Remove all the emitters from the system

### getPositionX

    public float getPositionX()

  Get the x coordiante of the position of the system

  Returns:
    The x coordinate of the position of the system

### getPositionY

    public float getPositionY()

  Get the y coordiante of the position of the system

  Returns:
    The y coordinate of the position of the system

### setPosition

    public void setPosition(float x,
                            float y)

  Set the position at which this system should render relative to the current graphics context setup

  Parameters:
    `x` - The x coordinate at which this system should be centered
    `y` - The y coordinate at which this system should be centered

### render

    public void render()

  Render the particles in the system

### render

    public void render(float x,
                       float y)

  Render the particles in the system

  Parameters:
    `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)

### update

    public void update(int delta)

  Update the system, request the assigned emitters update the particles

  Parameters:
    `delta` - The amount of time thats passed since last update in milliseconds

### getParticleCount

    public int getParticleCount()

  Get the number of particles in use in this system

  Returns:
    The number of particles in use in this system

### getNewParticle

    public Particle getNewParticle(ParticleEmitter emitter,
                                   float life)

  Get a new particle from the system. This should be used by emitters to request particles

  Parameters:
    `emitter` - The emitter requesting the particle
    `life` - The time the new particle should live for
  Returns:
    A particle from the system

### release

    public void release(Particle particle)

  Release a particle back to the system once it has expired

  Parameters:
    `particle` - The particle to be released

### releaseAll

    public void releaseAll(ParticleEmitter emitter)

  Release all the particles owned by the specified emitter

  Parameters:
    `emitter` - The emitter owning the particles that should be released

### moveAll

    public void moveAll(ParticleEmitter emitter,
                        float x,
                        float y)

  Move all the particles owned by the specified emitter

  Parameters:
    `emitter` - The emitter owning the particles that should be released
    `x` - The amount on the x axis to move the particles
    `y` - The amount on the y axis to move the particles

### duplicate

    public ParticleSystem duplicate()
                             throws SlickException

  Create a duplicate of this system. This would have been nicer as a different interface but may cause to much API change headache. Maybe next full version release it should be rethought. TODO: Consider refactor at next point release

  Returns:
    A copy of this particle system
  Throws:
    `SlickException` - Indicates a failure during copy or a invalid particle system to be duplicated

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006 New Dawn Software. All Rights Reserved.