Search in sources :

Example 1 with ParticleEffectPool

use of com.badlogic.gdx.graphics.g2d.ParticleEffectPool in project libgdx by libgdx.

the class ParticleEmittersTest method create.

@Override
public void create() {
    spriteBatch = new SpriteBatch();
    effect = new ParticleEffect();
    effect.load(Gdx.files.internal("data/singleTextureAllAdditive.p"), Gdx.files.internal("data"));
    effect.setPosition(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    effectPool = new ParticleEffectPool(effect, 20, 20);
    setupUI();
    InputProcessor inputProcessor = new InputAdapter() {

        public boolean touchDragged(int x, int y, int pointer) {
            if (latestEffect != null)
                latestEffect.setPosition(x, Gdx.graphics.getHeight() - y);
            return false;
        }

        public boolean touchDown(int x, int y, int pointer, int newParam) {
            latestEffect = effectPool.obtain();
            latestEffect.setEmittersCleanUpBlendFunction(!skipCleanup.isChecked());
            latestEffect.setPosition(x, Gdx.graphics.getHeight() - y);
            effects.add(latestEffect);
            return false;
        }
    };
    InputMultiplexer multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(ui);
    multiplexer.addProcessor(inputProcessor);
    Gdx.input.setInputProcessor(multiplexer);
}
Also used : ParticleEffect(com.badlogic.gdx.graphics.g2d.ParticleEffect) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) InputAdapter(com.badlogic.gdx.InputAdapter) ParticleEffectPool(com.badlogic.gdx.graphics.g2d.ParticleEffectPool) InputProcessor(com.badlogic.gdx.InputProcessor) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Aggregations

InputAdapter (com.badlogic.gdx.InputAdapter)1 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 InputProcessor (com.badlogic.gdx.InputProcessor)1 ParticleEffect (com.badlogic.gdx.graphics.g2d.ParticleEffect)1 ParticleEffectPool (com.badlogic.gdx.graphics.g2d.ParticleEffectPool)1 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)1