Java 类com.badlogic.gdx.graphics.g2d.ParticleEffectPool 实例源码

项目:KyperBox    文件:GameState.java   
public GameState(String name, String tmx, StateManager manager) {
    this.tmx = tmx;
    setManager(manager);
    if(name!=null)
    this.name = name;
    else
        this.name = "";
    sprites = new ObjectMap<String, Sprite>();
    animations = new ObjectMap<String, Animation<String>>();
    fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats
    particle_effects = new ObjectMap<String, ParticleEffectPool>();
    pvalues = new Array<String>();
    time_scale = 1f;
    shaders = new ObjectMap<String, ShaderProgram>();
    svalues = new Array<String>();
}
项目:KyperBox    文件:GameState.java   
private void loadParticleEffects(TiledMap data, String atlasname) {
    MapObjects objects = data.getLayers().get("preload").getObjects();
    String ppcheck = "Particle";
    for (MapObject o : objects) {
        String name = o.getName();
        MapProperties properties = o.getProperties();
        String type = properties.get("type", String.class);
        if (type != null && type.equals(ppcheck)) {
            String file = properties.get("particle_file", String.class);
            if (file != null) {
                game.loadParticleEffect(file, atlasname);
                game.getAssetManager().finishLoading();
                if (!particle_effects.containsKey(name)) {
                    ParticleEffect pe = game.getParticleEffect(file);
                    pe.setEmittersCleanUpBlendFunction(false);
                    pvalues.add(KyperBoxGame.PARTICLE_FOLDER + KyperBoxGame.FILE_SEPARATOR + file);
                    particle_effects.put(name, new ParticleEffectPool(pe, 12, 48));
                }
            }
        }
    }
}
项目:dice-heroes    文件:RangedDamageVisualizer.java   
@Override public IFuture<Void> visualize(RangedDamageResult result) {
    final Future<Void> future = new Future<Void>();
    SoundManager.instance.playSound("ability-firestorm");
    if (Config.particles.exists("ability-" + result.ability.name + "-hit")) {
        ParticleEffectPool effectPool = Config.particles.get("ability-" + result.ability.name + "-hit");
        ParticleActor actor = new ParticleActor(effectPool.obtain());
        visualizer.viewController.effectLayer.addActor(actor);
        actor.freeOnComplete();
        actor.setPosition(
            result.target.getX() * ViewController.CELL_SIZE + ViewController.CELL_SIZE / 2,
            result.target.getY() * ViewController.CELL_SIZE + ViewController.CELL_SIZE / 2
        );
    }
    if (result.success) {
        visualizer.viewController.visualize(new Death(result.creature, result.target)).addListener(future);
    } else {
        visualizer.viewController.visualize(new Defence(result.target, AttackType.weapon)).addListener(future);
    }
    return future;
}
项目:sioncore    文件:ParticleEffectPools.java   
public ParticleEffectPools() {
    logger = new Logger(TAG, Env.debugLevel);

    logger.info("initialising");

    pools = new ObjectMap<String, ParticleEffectPool>();

    try {
        JsonReader reader = new JsonReader();
        JsonValue root = reader.parse(Gdx.files.internal(PARTICLES_FILE));
        JsonIterator particlesIt = root.iterator();

        while (particlesIt.hasNext()) {
            JsonValue particleValue = particlesIt.next();
            String effectName = particleValue.asString();
            logger.info("loading " + effectName);
            ParticleEffect effect = new ParticleEffect();
            effect.load(Gdx.files.internal(effectName), Gdx.files.internal(PARTICLES_FOLDER));

            pools.put(effectName, new ParticleEffectPool(effect,
                                                         Env.particlePoolInitialCapacity,
                                                         Env.particlePoolMaxCapacity));
        }
    }
    catch (Exception e) {
        logger.error("failed to list directory " + PARTICLES_FILE);
    }
}
项目:CatchDROP    文件:PoisonDrop.java   
public PoisonDrop(final CDGame game) {
    super(game);
    x = MathUtils.random(0, game.GAME_WIDTH-64);
    y = game.GAME_HEIGHT;
    width = 64;
    height = 64;
    loseOnMiss = false;
    gainValue = 0;
    loseValue = 2;
    rectImg = new Texture("poison.png");

    poisonTimer = 10;
    nowTimeInSeconds = TimeUtils.nanosToMillis(TimeUtils.nanoTime())/1000;
    lastTimeInSeconds = nowTimeInSeconds;

    fireEffect = new ParticleEffect();
    fireEffect.load(Gdx.files.internal("fire.p"), Gdx.files.internal(""));
    fireEffectPool = new ParticleEffectPool(fireEffect, 1, 2);
    firePEffect = fireEffectPool.obtain();
}
项目:CatchDROP    文件:PoisonDrop.java   
public PoisonDrop(final CDGame game, float x, float y, BitmapFont timerFont) {
    super(game);
    this.x = x;
    this.y = y;
    width = 64;
    height = 64;
    loseOnMiss = false;
    gainValue = 0;
    loseValue = 2;
    rectImg = new Texture("poison.png");

    poisonTimer = 10;
    nowTimeInSeconds = TimeUtils.nanosToMillis(TimeUtils.nanoTime())/1000;
    lastTimeInSeconds = nowTimeInSeconds;

    fireEffect = new ParticleEffect();
    fireEffect.load(Gdx.files.internal("fire.p"), Gdx.files.internal(""));
    fireEffectPool = new ParticleEffectPool(fireEffect, 1, 2);
    firePEffect = fireEffectPool.obtain();

    this.timerFont = timerFont;
}
项目:touhou-java    文件:ParticleScreen.java   
private void addEffect(String effectName, String imgName) {
    ParticleEffect reffect = new ParticleEffect();
    TextureAtlas atlas = new TextureAtlas();
    atlas.addRegion(
            imgName,
            new TextureRegion(new Texture(Gdx.files.internal("particles/"
                    + imgName + ".png"))));
    reffect.load(Gdx.files.internal("particles/" + effectName + ".p"),
            atlas);
    EffectPool = new ParticleEffectPool(reffect, 1, 2);

    // Create effect
    PooledEffect effect = EffectPool.obtain();
    effect.setPosition(Gdx.graphics.getWidth() / 2,
            Gdx.graphics.getHeight() / 2);
    effects.add(effect);
}
项目:GDX-Engine    文件:ParticleEffectManager.java   
/**
 * Add new (and activate) the effect just has been added.
 * @param key key of effect
 * @param particleEffectFilePath File path of effect file
 * @param dirPathOfImages path of folder that contains images for effect 
 * @param isActiveEffect set Active Effect for effect just has been added.
 */
public void addParticleEffect(String key, String particleEffectFilePath, String dirPathOfImages){

    if(collection.containsKey(key))
    {
        throw new GdxRuntimeException("Key for the particle effect is existing!");
    }

    ParticleEffect effect = new ParticleEffect();
    effect.load(Gdx.files.internal(particleEffectFilePath),Gdx.files.internal(dirPathOfImages));
    ParticleEffectPool pool =  new ParticleEffectPool(effect, 1, 2);
    collection.put(key, pool);
}
项目:KyperBox    文件:ParticleSystem.java   
@Override
public void init(MapProperties properties) {
    effects = new ArrayMap<GameObject, ParticleEffectPool.PooledEffect>();
    pre_draws = new Array<ParticleEffectPool.PooledEffect>();
    post_draws = new Array<ParticleEffectPool.PooledEffect>();
    pos_check = new Vector2();
    cam = getLayer().getCamera();
    last_zoom = cam.getZoom();
    pcomp = new ParticleComparator();
}
项目:nomoore    文件:Particles.java   
private void render(SpriteBatch batch, float delta, float x, float y, ParticleEffectPool.PooledEffect[] pooledEffect) {
    for (ParticleEffectPool.PooledEffect effect : pooledEffect) {
        effect.setPosition(x, y);
        effect.draw(batch, delta);
        if (effect.isComplete()) {
            resetFireworksEffect(effect);
        }
    }
    resetBlendFunction(batch);
}
项目:jewelthief    文件:Particles.java   
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
    };

    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;
    }
}
项目:jewelthief    文件:Particles.java   
/**
 * Renders the fireworks effects on the given batch and resets each effect if it has reached its end.
 *
 * @param batch
 * @param delta
 */
public void renderFireworks(SpriteBatch batch, float delta) {
    for (ParticleEffectPool.PooledEffect effect : fireworkEffects) {
        effect.draw(batch, delta);
        if (effect.isComplete()) {
            resetFireworksEffect(effect);
        }
    }
    resetBlendFunction(batch);
}
项目:jewelthief    文件:Particles.java   
/**
 * Frees all allocated resources.
 */
public void dispose() {
    for (ParticleEffectPool.PooledEffect effect : fireworkEffects) {
        effect.free();
        effect.dispose();
    }
    fireworksEffectPool.clear();
}
项目:Escapy    文件:EscapyWeather.java   
public EscapyWeather(float scrW, float scrH, String[] pFile, String[] pImg, String[] names){
    weatherArray = new EscapyNamedArray<>(ParticleEffectPool.class);
    batch = new SpriteBatch();
    SCR_W = scrW;
    SCR_H = scrH;
    load(pFile, pImg, names);
}
项目:Escapy    文件:EscapyWeather.java   
public EscapyWeather(float scrW, float scrH, String pFile, String pImg, String name){
    weatherArray = new EscapyNamedArray<>(ParticleEffectPool.class);
    batch = new SpriteBatch();
    SCR_W = scrW;
    SCR_H = scrH;
    load(pFile, pImg, name);
}
项目:Escapy    文件:EscapyWeather.java   
public EscapyWeather setWeather(String name) {
    if (name != null) {
        if (actual != null) {
            Arrays.stream(actual).forEach(ParticleEffectPool.PooledEffect::free);
        }
        actual = new ParticleEffectPool.PooledEffect[3];
        float[] ps = new float[]{ -SCR_W, 0, SCR_W };
        for (int i = 0; i < actual.length; i++) {
            actual[i] = weatherArray.get(name).obtain();
            actual[i].flipY();
            actual[i].setPosition(ps[i] + startPoint[0], startPoint[1] - 50);
        }
    }
    return this;
}
项目:Escapy    文件:EscapyWeather.java   
public EscapyWeather load(String[] pFile, String[] pImg, String[] names) {

        for (int i = 0; i < pFile.length; i++) {

            ParticleEffect tmp = new ParticleEffect();
            tmp.load(new FileHandle(pFile[i]), new FileHandle(pImg[i]));
            tmp.setPosition(0, -50);
            weatherArray.addSource(new ParticleEffectPool(tmp, 0, 10), names[i]);
        }
        return this;
    }
项目:libgdxjam    文件:ParticleSystem.java   
@Override
public void dispose() {
    logger.info("dispose");

    for (ParticleEffectPool pool : pools.values()) {
        pool.clear();
    }
}
项目:clouboy    文件:ParticleRenderer.java   
public ParticleRenderer() {
  singleEffects = new CopyOnWriteArrayList<PooledEffect>();
  pools = new HashMap<String, ParticleEffectPool>();
  effects = new HashMap<GameObject, PooledEffect>();
  mapping = new HashMap<GameObject, String>();
  offsets = new HashMap<GameObject, Vector2>();
  objects = new HashMap<PooledEffect, GameObject>();
}
项目:clouboy    文件:ParticleRenderer.java   
public PooledEffect getEffect(GameObject object) {
  PooledEffect effect = effects.get(object);
  if (effect != null) {
    return effect;
  } else if (mapping.containsKey(object)) {
    String id = mapping.get(object);
    ParticleEffectPool pool = pools.get(id);
    effect = pool.obtain();
    effects.put(object, effect);
    return effect;
  } else {
    return null;
  }
}
项目:clouboy    文件:ParticleRenderer.java   
public void applyParticleEffect(String id, float x, float y) {
  ensurePool(id);
  ParticleEffectPool pool = pools.get(id);
  PooledEffect effect = pool.obtain();
  effect.setPosition(x, y);
  singleEffects.add(effect);

}
项目:braingdx    文件:ParticleManager.java   
public boolean free(ManagedParticleEffect effect, boolean force) {
   if (force || effect.getEffect().isComplete()) {
      effect.getEffect().free();
      ParticleEffectPool pool = pools.get(effect.getPath());
      pool.free(effect.getEffect());
      return true;
   }
   return false;
}
项目:braingdx    文件:ParticleManager.java   
@Override
public void dispose() {
   for (ParticleEffectPool pool : pools.values()) {
      pool.clear();
   }
   pools.clear();
}
项目:ud405    文件:UdacityScreen.java   
@Override
public void show() {
    batch = new SpriteBatch();
    logo = new Texture("udacity_logo_white.png");
    logoHeight = logo.getHeight() * LOGO_WIDTH / logo.getWidth();

    ParticleEffect touchEffect = new ParticleEffect();
    touchEffect.load(Gdx.files.internal("UdacityEmitter.p"), Gdx.files.internal(""));
    touchEffect.setEmittersCleanUpBlendFunction(false);
    touchEffectPool = new ParticleEffectPool(touchEffect, 1, 2);
    Gdx.input.setInputProcessor(this);
}
项目:GDXJam    文件:ParticleSystem.java   
public void loadTemplates () {
    for (int i = 0; i < ParticleType.values().length; i++) {
        ParticleEffect template = new ParticleEffect();
        template.load(Gdx.files.internal(ROOT_DIR + ParticleType.values()[i].file), Gdx.files.internal(ROOT_DIR));
        template.scaleEffect(0.02f);
        effectTemplates.add(template);

        ParticleEffectPool pool = new ParticleEffectPool(template, 4, 20);
        effectPools.add(pool);
    }
}
项目:ud406    文件:UdacityScreen.java   
@Override
public void show() {
    batch = new SpriteBatch();
    // TODO: Scavenger hunt! Where does this logo live?
    logo = new Texture("udacity_logo_white.png");
    logoHeight = logo.getHeight() * LOGO_WIDTH / logo.getWidth();

    ParticleEffect touchEffect = new ParticleEffect();
    // TODO: Same question. Where does UdacityEmitter.p live? How are we loading it?
    touchEffect.load(Gdx.files.internal("UdacityEmitter.p"), Gdx.files.internal(""));
    touchEffect.setEmittersCleanUpBlendFunction(false);
    touchEffectPool = new ParticleEffectPool(touchEffect, 1, 2);
    Gdx.input.setInputProcessor(this);
}
项目:sioncore    文件:ParticleEffectPools.java   
public PooledEffect obtain(String name) {
    ParticleEffectPool pool = pools.get(name);

    if (pool == null) {
        logger.error("pool not found " + name);
        return null;
    }

    return pool.obtain();
}
项目:sioncore    文件:ParticleEffectPools.java   
public void free(PooledEffect effect) {
    Values<ParticleEffectPool> values = pools.values();

    while (values.hasNext) {
        values.next().free(effect);
    }
}
项目:sioncore    文件:ParticleEffectPools.java   
public void clear() {
    Values<ParticleEffectPool> values = pools.values();

    while (values.hasNext) {
        values.next().clear();
    }
}
项目:Simple-Isometric-Game    文件:EffectManager.java   
@Override
public void createEffect(int x, int y, Effect effectType) {
    if(effectType == Effect.COIN_EFFECT) {
        ParticleEffectPool.PooledEffect prt = particleManager.obtainEffect(ParticleManager.COIN_EFFECT);
        prt.setPosition(x, y);
        particleManager.addEffect(prt);

        // Play sound effect
        coinSound.play();
    } else {
        throw new IllegalArgumentException("Unknown effectType");
    }
}
项目:Simple-Isometric-Game    文件:ParticleManager.java   
public ParticleManager() {
    ParticleEffect temp;

    // COIN_EFFECT = 0
    temp = IsometricGame.assets.get("particles/coin.p", ParticleEffect.class);
    effectPools.add(new ParticleEffectPool(temp, 10, 100));

}
项目:Simple-Isometric-Game    文件:ParticleManager.java   
public void update(float dt) {
    for (int i = runningEffects.size - 1; i >= 0; i--) {
        ParticleEffectPool.PooledEffect effect = runningEffects.get(i);
        effect.update(dt);
        if (effect.isComplete()) {
            effect.free();
            runningEffects.removeIndex(i);
        }
    }

}
项目:touhou-java    文件:Resources.java   
public void LoadPSPool(String particlepoolname, String filename,
        String imagename) {
    Image img = images.get(imagename);
    ParticleEffect pe = new ParticleEffect();
    TextureAtlas atlas = new TextureAtlas();
    atlas.addRegion(imagename, img);
    pe.load(Gdx.files.internal(filename), atlas);
    ParticleEffectPool pool = new ParticleEffectPool(pe, 1, 10);
    particlePools.put(particlepoolname, pool);
}
项目:jewelthief    文件:Particles.java   
/**
 * Resets the position, start color and duration of all firework effects to random values.
 */
public void resetFireworksEffects() {
    for (ParticleEffectPool.PooledEffect effect : fireworkEffects) {
        resetFireworksEffect(effect);
    }
}
项目:Escapy    文件:EscapyWeather.java   
public EscapyWeather(float scrW, float scrH){
    weatherArray = new EscapyNamedArray<>(ParticleEffectPool.class);
    batch = new SpriteBatch();
    SCR_W = scrW;
    SCR_H = scrH;
}
项目:Escapy    文件:EscapyWeather.java   
public EscapyWeather setFunc(Consumer<ParticleEffectPool.PooledEffect> cons) {
    if (actual != null) Arrays.stream(actual).forEach(cons);
    return this;
}
项目:gdxjam-ugg    文件:RenderableParticle.java   
public void setEffect(ParticleEffectPool.PooledEffect effect){
    this.pooledEffect = effect;
}
项目:dice-heroes    文件:Particles.java   
public Particles(ObjectMap<String, ParticleEffectPool> data) {
    this.data = data;
}
项目:dice-heroes    文件:Particles.java   
public ParticleEffectPool get(String name) {
    if (!data.containsKey(name))
        throw new IllegalArgumentException("there is no such particle: " + name);
    return data.get(name);
}
项目:dice-heroes    文件:ParticleActor.java   
public ParticleActor(ParticleEffectPool.PooledEffect effect) {
    this.effect = effect;
}