Example usage for com.badlogic.gdx.graphics.g2d ParticleEffect reset

List of usage examples for com.badlogic.gdx.graphics.g2d ParticleEffect reset

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics.g2d ParticleEffect reset.

Prototype

public void reset() 

Source Link

Usage

From source file:at.therefactory.jewelthief.ui.Particles.java

License:Open Source License

/**
 * Resets the position, start color and duration of the given firework effects to random values.
 *
 * @param effect//from ww w. ja  va  2 s. c  om
 */
private void resetFireworksEffect(ParticleEffect effect) {
    effect.reset();
    effect.setDuration(Utils.randomWithin(180, 250));
    effect.setPosition(Utils.randomWithin(0, WINDOW_WIDTH), Utils.randomWithin(0, WINDOW_HEIGHT));
    float[] colors = effect.getEmitters().get(0).getTint().getColors();
    int randomStartColor = Utils.randomWithin(0, startColors.length - 1);
    for (int i = 0; i < 6; i++) {
        colors[i] = startColors[randomStartColor][i % 3];
    }
    for (ParticleEmitter emitter : effect.getEmitters()) {
        emitter.getTint().setColors(colors);
    }
}

From source file:com.kotcrab.vis.runtime.system.render.ParticleRenderSystem.java

License:Apache License

@Override
protected void process(int entityId) {
    VisParticle particle = particleCm.get(entityId);
    Transform transform = transformCm.get(entityId);

    ParticleEffect effect = particle.getEffect();

    if (transform.isDirty()) {
        particle.updateValues(transform.getX(), transform.getY());
    }//from ww w .  j a va2 s.  c  o  m

    if (ignoreActive || particle.isActiveOnStart())
        effect.update(world.delta);

    effect.draw(batch);

    if (effect.isComplete())
        effect.reset();
}

From source file:net.bplaced.therefactory.nomoore.utils.Particles.java

License:Open Source License

/**
 * Resets the position, start color and duration of the given firework effects to random values.
 *
 * @param effect//w ww.  j  av  a  2  s.  c  o  m
 */
private void resetFireworksEffect(ParticleEffect effect) {
    effect.reset();
    effect.setDuration(Utils.randomWithin(180, 250));
    //        effect.setPosition(Utils.randomWithin(0, WINDOW_WIDTH), Utils.randomWithin(0, WINDOW_HEIGHT));
}

From source file:net.ivang.axonix.main.actors.game.level.blocks.BlocksParticlesHolder.java

License:Apache License

@Subscribe
@SuppressWarnings("unused")
public void onBlockDestruction(DestroyBlockIntent intent) {
    ParticleEffect effect = null;
    // get some idle effect
    for (ParticleEffect particleEffect : particleEffects) {
        if (particleEffect.isComplete()) {
            effect = particleEffect;/*from w  w  w  .  j a v a2 s  .  c  o  m*/
            break;
        }
    }
    // or create new one
    if (effect == null) {
        effect = new ParticleEffect();
        effect.load(Gdx.files.internal("data/particles/block_blue.p"), skin.getAtlas());
        particleEffects.add(effect);
    }
    // and (re)run it
    Block block = intent.getBlock();
    effect.setPosition(block.getX() + 0.5f, block.getY() + 0.5f);
    effect.reset();
}

From source file:org.lightjason.examples.pokemon.ui.CParticleSystem.java

License:LGPL

/**
 * runs the particel effect immediatly//from  w w w. jav a  2 s  . co  m
 *
 * @param p_name name effect
 * @param p_position emitter position
 * @return self reference
 */
public final CParticleSystem execute(final String p_name, final DoubleMatrix1D p_position) {
    final ParticleEffect l_base = m_effects.get(CParticleSystem.name(p_name));
    if (l_base == null)
        throw new RuntimeException(MessageFormat.format("particle effect [{0}] not found", p_name));

    final ParticleEffect l_effect = new ParticleEffect(l_base);
    l_effect.setPosition((float) p_position.getQuick(1), (float) p_position.getQuick(0));
    m_active.add(l_effect);
    l_effect.reset();
    l_effect.start();
    return this;
}