Search in sources :

Example 1 with TextParticle

use of de.gurkenlabs.litiengine.graphics.particles.TextParticle 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;
}
Also used : Particle(de.gurkenlabs.litiengine.graphics.particles.Particle) TextParticle(de.gurkenlabs.litiengine.graphics.particles.TextParticle) RectangleFillParticle(de.gurkenlabs.litiengine.graphics.particles.RectangleFillParticle) OvalParticle(de.gurkenlabs.litiengine.graphics.particles.OvalParticle) RightLineParticle(de.gurkenlabs.litiengine.graphics.particles.RightLineParticle) ShimmerParticle(de.gurkenlabs.litiengine.graphics.particles.ShimmerParticle) RectangleOutlineParticle(de.gurkenlabs.litiengine.graphics.particles.RectangleOutlineParticle) LeftLineParticle(de.gurkenlabs.litiengine.graphics.particles.LeftLineParticle) SpriteParticle(de.gurkenlabs.litiengine.graphics.particles.SpriteParticle) RectangleFillParticle(de.gurkenlabs.litiengine.graphics.particles.RectangleFillParticle) RectangleOutlineParticle(de.gurkenlabs.litiengine.graphics.particles.RectangleOutlineParticle) Spritesheet(de.gurkenlabs.litiengine.graphics.Spritesheet) TextParticle(de.gurkenlabs.litiengine.graphics.particles.TextParticle) SpriteParticle(de.gurkenlabs.litiengine.graphics.particles.SpriteParticle) LeftLineParticle(de.gurkenlabs.litiengine.graphics.particles.LeftLineParticle) RightLineParticle(de.gurkenlabs.litiengine.graphics.particles.RightLineParticle) OvalParticle(de.gurkenlabs.litiengine.graphics.particles.OvalParticle) ShimmerParticle(de.gurkenlabs.litiengine.graphics.particles.ShimmerParticle)

Aggregations

Spritesheet (de.gurkenlabs.litiengine.graphics.Spritesheet)1 LeftLineParticle (de.gurkenlabs.litiengine.graphics.particles.LeftLineParticle)1 OvalParticle (de.gurkenlabs.litiengine.graphics.particles.OvalParticle)1 Particle (de.gurkenlabs.litiengine.graphics.particles.Particle)1 RectangleFillParticle (de.gurkenlabs.litiengine.graphics.particles.RectangleFillParticle)1 RectangleOutlineParticle (de.gurkenlabs.litiengine.graphics.particles.RectangleOutlineParticle)1 RightLineParticle (de.gurkenlabs.litiengine.graphics.particles.RightLineParticle)1 ShimmerParticle (de.gurkenlabs.litiengine.graphics.particles.ShimmerParticle)1 SpriteParticle (de.gurkenlabs.litiengine.graphics.particles.SpriteParticle)1 TextParticle (de.gurkenlabs.litiengine.graphics.particles.TextParticle)1