use of de.gurkenlabs.litiengine.graphics.particles.SpriteParticle in project litiengine by gurkenlabs.
the class SpritesheetEmitter method createNewParticle.
@Override
protected Particle createNewParticle() {
final int life = this.getRandomParticleTTL();
final SpriteParticle p = new SpriteParticle(this.getRandomSprite(), life);
return p;
}
use of de.gurkenlabs.litiengine.graphics.particles.SpriteParticle in project litiengine by gurkenlabs.
the class CustomEmitter method createNewParticle.
@Override
protected Particle createNewParticle() {
float x;
float y;
float deltaX;
float deltaY;
float gravityX;
float gravityY;
float width;
float height;
float deltaWidth;
float deltaHeight;
x = this.getEmitterData().getParticleX().get();
y = this.getEmitterData().getParticleY().get();
deltaX = this.getEmitterData().getDeltaX().get();
deltaY = this.getEmitterData().getDeltaY().get();
gravityX = this.getEmitterData().getGravityX().get();
gravityY = this.getEmitterData().getGravityY().get();
width = this.getEmitterData().getParticleWidth().get();
height = this.getEmitterData().getParticleHeight().get();
deltaWidth = this.getEmitterData().getDeltaWidth().get();
deltaHeight = this.getEmitterData().getDeltaHeight().get();
Particle particle;
switch(this.getEmitterData().getParticleType()) {
case LEFTLINE:
particle = new LeftLineParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case DISC:
particle = new OvalParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case RECTANGLE:
particle = new RectangleFillParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case RECTANGLE_OUTLINE:
particle = new RectangleOutlineParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case RIGHTLINE:
particle = new RightLineParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case SHIMMER:
particle = new ShimmerParticle(new Rectangle2D.Float(x, y, this.getWidth(), this.getHeight()), width, height, this.getRandomParticleColor()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case TEXT:
particle = new TextParticle(this.getEmitterData().getParticleText(), this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
case SPRITE:
Spritesheet sprite = Spritesheet.find(this.getEmitterData().getSpritesheet());
if (sprite == null) {
return null;
}
particle = new SpriteParticle(sprite.getSprite(MathUtilities.randomInRange(0, sprite.getTotalNumberOfSprites() - 1)), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
default:
particle = new RectangleFillParticle(width, height, this.getRandomParticleColor(), this.getRandomParticleTTL()).setX(x).setY(y).setDeltaIncX(gravityX).setDeltaIncY(gravityY).setDeltaX(deltaX).setDeltaY(deltaY).setDeltaWidth(deltaWidth).setDeltaHeight(deltaHeight);
break;
}
particle.setDeltaWidth(deltaWidth);
particle.setDeltaHeight(deltaHeight);
particle.setCollisionType(this.getEmitterData().getCollisionType());
return particle;
}
Aggregations