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

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

Introduction

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

Prototype

public void load(FileHandle effectFile, TextureAtlas atlas) 

Source Link

Usage

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

License:Open Source License

public Particles(TextureAtlas textureAtlas) {
    fireworkEffects = new ParticleEffectPool.PooledEffect[5];
    startColors = new float[][] { //
            new float[] { 0, .58f, 1 }, // blue
            new float[] { 1, .984f, .267f }, // yellow
            new float[] { .969f, .11f, 1 }, // pink
            new float[] { 1, .02f, .082f }, // red
            new float[] { .816f, 0, 1 }, // violet
            new float[] { 0, 1, .098f }, // green
    };/*  w w  w .j  a  v a 2  s.co m*/

    ParticleEffect fireworksEffect = new ParticleEffect();
    fireworksEffect.load(Gdx.files.internal("particles/fireworks.p"), textureAtlas);

    // if particle effect includes additive or pre-multiplied particle emitters
    // you can turn off blend function clean-up to save a lot of draw calls
    // but remember to switch the Batch back to GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
    // before drawing "regular" sprites or your Stage.
    fireworksEffect.setEmittersCleanUpBlendFunction(false);

    fireworksEffectPool = new ParticleEffectPool(fireworksEffect, 1, 5);
    for (int i = 0; i < fireworkEffects.length; i++) {
        ParticleEffectPool.PooledEffect effect = fireworksEffectPool.obtain();
        resetFireworksEffect(effect);
        fireworkEffects[i] = effect;
    }
}

From source file:com.kotcrab.vis.editor.module.project.ParticleCacheModule.java

License:Apache License

private ParticleEffect get(FileHandle file, float scaleFactor) {
    ParticleEffect effect = new ParticleEffect();

    try {//from w ww .  j a v a  2 s .  com
        effect.load(file, file.parent());
    } catch (GdxRuntimeException e) {
        throw new EditorRuntimeException(e);
    }

    effect.scaleEffect(scaleFactor);
    return effect;
}

From source file:com.quadbits.gdxhelper.scenemodel.handlers.ParticleEffectActorModelHandler.java

License:Apache License

@Override
public Object create(BaseModel model, String id, boolean forceCreation) {
    // Safeguard against duplicate calls
    if (!forceCreation && model.created) {
        return null;
    }/*from  www  . ja  v a2  s.  c om*/
    model.created = true;

    // Id
    if (id == null) {
        id = model.id;
    }

    ParticleEffectActorModel actorModel = (ParticleEffectActorModel) model;
    HashMap<String, Actor> allActors = sceneModelManager.getAllActors();
    ArrayList<Actor> resizeableActorsAbsolute = sceneModelManager.getResizeableActorsAbsolute();
    HashMap<String, Controller> allControllers = sceneModelManager.getAllControllers();
    HashMap<String, ParticleEffectPool> particleEffectPools = sceneModelManager.getParticleEffectPools();

    // Get parent
    Group parent = null;
    if (actorModel.parent != null && actorModel.addToParent) {
        parent = (Group) allActors.get(actorModel.parent);
    }

    // Create particle effect actor
    ParticleEffectActor actor = particleEffectActorPool.obtain();
    actor.setName(id);
    if (parent != null) {
        parent.addActor(actor);
    }
    allActors.put(id, actor);
    resizeableActorsAbsolute.add(actor);

    // Get pooled effect from pool, create pool if it does not exist
    ParticleEffectPool effectPool = particleEffectPools.get(actorModel.effectFile);
    if (effectPool == null) {
        ParticleEffect prototype = new ParticleEffect();
        if (actorModel.atlasPrefix == null) {
            prototype.load(Gdx.files.internal(actorModel.effectFile), textureAtlasProxy.get());
        } else {
            prototype.load(Gdx.files.internal(actorModel.effectFile), textureAtlasProxy.get(),
                    actorModel.atlasPrefix);
        }
        effectPool = new ParticleEffectPool(prototype, 1, 70);
        particleEffectPools.put(actorModel.effectFile, effectPool);
        //            prototype.dispose();
    }
    ParticleEffectPool.PooledEffect effect = effectPool.obtain();
    effect.start();
    actor.setEffect(effect);

    // Process controllers
    if (actorModel.controllers != null) {
        for (String controllerId : actorModel.controllers) {
            Controller controller = allControllers.get(controllerId);
            if (controller != null) {
                actor.addController(controller);
            }
        }
    }

    return actor;
}

From source file:com.ridiculousRPG.event.EventObject.java

License:Apache License

private ParticleEffect loadParticleEffect(final FileHandle fh) {
    final ParticleEffect effect = new ParticleEffect();
    new ExecWithGlContext() {
        @Override// w  ww.ja  v  a2s . c  o  m
        public void exec() {
            effect.load(fh, fh.parent());
        }
    }.runWait();
    effect.setPosition(drawBound.x + drawBound.width * .5f, drawBound.y);
    visible = true;
    return effect;
}

From source file:com.sawan.mathattack.utils.UtilsAssets.java

License:Open Source License

/**
 * Load a particle.//from  w w w . java  2s .c  om
 *
 * @param file the file
 * @param imageMainDir the image main dir
 * @return the particle effect
 */
public static ParticleEffect loadParticle(String file, String imageMainDir) {
    ParticleEffect pe = new ParticleEffect();
    pe.load(Gdx.files.internal(file + ".p"), Gdx.files.internal(imageMainDir));
    return pe;
}

From source file:com.turbogerm.germlibrary.util.ParticleEffectLoader.java

License:Open Source License

@Override
public ParticleEffect load(AssetManager assetManager, String fileName, ParticleEffectParameter parameter) {
    ParticleEffect effect = new ParticleEffect();
    FileHandle effectFile = resolve(fileName);
    if (parameter.atlasName != null) {
        effect.load(effectFile, (TextureAtlas) parameter.assetManager.get(parameter.atlasName));
    } else {//www. j a v a2 s  .c  om
        FileHandle imgDir = effectFile.parent();
        effect.load(effectFile, imgDir);
    }
    return effect;
}

From source file:de.bitbrain.craft.loader.ParticleLoader.java

License:Open Source License

@Override
public ParticleEffect load(AssetManager assetManager, String fileName, FileHandle file,
        ParticleParameter parameter) {/*w  w w.ja v  a  2  s.c  o m*/
    ParticleEffect effect = new ParticleEffect();
    effect.load(file, Gdx.files.internal(Assets.DIR_PARTICLES));
    return effect;
}

From source file:io.github.deathsbreedgames.spacerun.screens.GameScreen.java

public GameScreen(AssetManager manager) {
    super("Splash", manager);

    // Create buttons
    mainStage = new Stage(new StretchViewport(GlobalVars.width, GlobalVars.height));
    buttonAtlas = manager.get("gfx/ui/buttons.pack", TextureAtlas.class);
    buttonSkin = new Skin(buttonAtlas);
    Gdx.input.setInputProcessor(mainStage);

    ImageButtonStyle imgBtnStyle = new ImageButtonStyle();
    imgBtnStyle.imageUp = buttonSkin.getDrawable("ExitButton");

    ImageButton exitButton = new ImageButton(imgBtnStyle);
    exitButton.setPosition(GlobalVars.width - (exitButton.getWidth() + 5f),
            GlobalVars.height - (exitButton.getHeight() + 5f));
    mainStage.addActor(exitButton);//w w w .j  ava  2  s .  co m
    exitButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent e, Actor a) {
            setNextScreen("MainMenu");
            setDone(true);
        }
    });

    // Setup draw stuff
    camera = new OrthographicCamera(GlobalVars.width, GlobalVars.height);
    camera.position.set(GlobalVars.width / 2, GlobalVars.height / 2, 0f);
    camera.update();

    batch = new SpriteBatch();
    spaceshipAtlas = manager.get("gfx/sprites/spaceships.pack", TextureAtlas.class);
    bulletAtlas = manager.get("gfx/sprites/bullets.pack", TextureAtlas.class);
    pickupAtlas = manager.get("gfx/sprites/pickups.pack", TextureAtlas.class);
    font = new BitmapFont();
    font.scale(0.01f);

    // Create ship
    if (GlobalVars.ship == 0) {
        player = new Player(spaceshipAtlas.findRegion("bluedestroyer"), 160, 50, 1, 1000, 250, 0.5f);
    } else if (GlobalVars.ship == 1) {
        player = new Player(spaceshipAtlas.findRegion("bluecarrier"), 160, 50, 0, 2000, 250, 0.5f);
    } else {
        player = new Player(spaceshipAtlas.findRegion("bluecruiser"), 160, 50, 0, 1000, 500, 0.5f);
    }
    // Setup enemies
    enemies = new Enemy[NUM_ENEMIES];
    for (int i = 0; i < NUM_ENEMIES; i++) {
        enemies[i] = null;
    }
    currentMaxEnemies = 1;
    currentEnemies = 0;
    // Setup bullets
    bullets = new Bullet[NUM_BULLETS];
    for (int i = 0; i < NUM_BULLETS; i++) {
        bullets[i] = null;
    }

    // Setup pickups
    pickup = null;
    pickupTimer = 0;

    rapidTimer = 0;
    speed = false;
    speedTimer = 0;
    invTimer = 0;

    // Setup Particle Effects
    ParticleEffect explosionEffect = new ParticleEffect();
    explosionEffect.load(Gdx.files.internal("gfx/particles/Explosion.p"), Gdx.files.internal("gfx/particles/"));
    explosionEffectPool = new ParticleEffectPool(explosionEffect, 1, 2);

    // Setup stars
    stars = new Star[NUM_STARS];
    for (int i = 0; i < NUM_STARS; i++) {
        RandomXS128 rand = new RandomXS128();
        stars[i] = new Star(rand.nextFloat() * GlobalVars.width, rand.nextFloat() * GlobalVars.height);
    }
    shapeRenderer = new ShapeRenderer();

    // Setup sound
    laserShot = Gdx.audio.newSound(Gdx.files.internal("sfx/laser5.mp3"));
    explode = Gdx.audio.newSound(Gdx.files.internal("sfx/explosion.mp3"));
}

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

License:Open Source License

public Particles() {
    bigFireEffect = new ParticleEffectPool.PooledEffect[5];
    smallFireEffect = new ParticleEffectPool.PooledEffect[5];
    TextureAtlas textureAtlas = new TextureAtlas("sprites/textures.pack");

    ParticleEffect fireworksEffect = new ParticleEffect();
    fireworksEffect.load(Gdx.files.internal("particles/fire.p"), textureAtlas);

    ParticleEffect smallFire = new ParticleEffect();
    smallFire.load(Gdx.files.internal("particles/fire_small.p"), textureAtlas);

    // if particle effect includes additive or pre-multiplied particle emitters
    // you can turn off blend function clean-up to save a lot of draw calls
    // but remember to switch the Batch back to GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA
    // before drawing "regular" sprites or your Stage.
    fireworksEffect.setEmittersCleanUpBlendFunction(false);
    smallFire.setEmittersCleanUpBlendFunction(false);

    bigFirePool = new ParticleEffectPool(fireworksEffect, 1, 5);
    smallFirePool = new ParticleEffectPool(smallFire, 1, 5);

    for (int i = 0; i < bigFireEffect.length; i++) {
        ParticleEffectPool.PooledEffect effect = bigFirePool.obtain();
        resetFireworksEffect(effect);/*  ww w  . j  a  v a2 s.  co m*/
        bigFireEffect[i] = effect;
    }

    for (int i = 0; i < smallFireEffect.length; i++) {
        ParticleEffectPool.PooledEffect effect = smallFirePool.obtain();
        resetFireworksEffect(effect);
        smallFireEffect[i] = effect;
    }
}

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;/* w  ww  .j a  va 2  s  .com*/
            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();
}