package de.gurkenlabs.litiengine.graphics.particles.emitters;

import java.awt.Image;
import java.awt.geom.Point2D;
import java.util.Random;

import de.gurkenlabs.litiengine.graphics.Spritesheet;
import de.gurkenlabs.litiengine.graphics.particles.Emitter;

public abstract class SpritesheetEmitter extends Emitter {
  private final Spritesheet spriteSheet;

  public SpritesheetEmitter(final Spritesheet spriteSheet, final Point2D origin) {
    super(origin);
    this.spriteSheet = spriteSheet;
  }

  public Spritesheet getSpritesheet() {
    return this.spriteSheet;
  }

  protected Image getRandomSprite() {
    return this.getSpritesheet().getSprite(new Random().nextInt(this.getSpritesheet().getTotalNumberOfSprites()));
  }
}

@@ -256,16 +256,146 @@
 mitter;%0D
+%0Aimport de.gurkenlabs.litiengine.graphics.particles.Particle;%0D%0Aimport de.gurkenlabs.litiengine.graphics.particles.SpriteParticle;%0D
 %0A%0D%0Apubli
@@ -879,11 +879,225 @@
 ;%0D%0A  %7D%0D%0A
+  %0D%0A  @Override%0D%0A  protected Particle createNewParticle() %7B%0D%0A    final int life = this.getRandomParticleTTL();%0D%0A%0D%0A    final SpriteParticle p = new SpriteParticle(this.getRandomSprite(), life);%0D%0A    return p;%0D%0A  %7D%0D%0A
 %7D%0D%0A

Improve SpritesheetEmitter.