当前位置: 首页>>代码示例>>Java>>正文


Java PooledEffect类代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect的典型用法代码示例。如果您正苦于以下问题:Java PooledEffect类的具体用法?Java PooledEffect怎么用?Java PooledEffect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PooledEffect类属于com.badlogic.gdx.graphics.g2d.ParticleEffectPool包,在下文中一共展示了PooledEffect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: gameObjectAdded

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public void gameObjectAdded(GameObject object, GameObject parent) {
	ParticleController pc = object.getController(ParticleController.class);
	if (pc != null) {
		PooledEffect pe = getLayer().getState().getEffect(pc.getEffectName());
		effects.put(object, pe);

		pe.setEmittersCleanUpBlendFunction(false);
		pos_check.set((getLayer().getX() / cam.getZoom() + object.getAbsoluteX() + pc.getRelativeX()) * cam.getZoom(),
				(getLayer().getY() / cam.getZoom() + object.getAbsoluteY() + pc.getRelativeY()) * cam.getZoom());
		pe.scaleEffect(pc.getXScaleFactor() * cam.getZoom(), pc.getYScaleFactor() * cam.getZoom(),
				pc.getMotionScaleFactor() * cam.getZoom());

		if (pc.isPostDraw()) {
			post_draws.add(pe);
		} else {
			pre_draws.add(pe);
		}
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:21,代码来源:ParticleSystem.java

示例2: preDraw

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
	public void preDraw(Batch batch, float parentAlpha) {
//		boolean last_additive = pre_draws.size > 0?containsAdditive(pre_draws.first()):false;
		
		for (int i = 0; i < pre_draws.size; i++) {
			PooledEffect pe = pre_draws.get(i);
			
//			boolean contains_additive = containsAdditive(pe);
//			if(last_additive&&!contains_additive) {
//				batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//			}
//			last_additive = contains_additive;
			
			pe.draw(batch);

		}
		
		batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
	}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:20,代码来源:ParticleSystem.java

示例3: postDraw

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
	public void postDraw(Batch batch, float parentAlpha) {
//		boolean last_additive = post_draws.size > 0?containsAdditive(post_draws.first()):false;
		for (int i = 0; i < post_draws.size; i++) {
			PooledEffect pe = post_draws.get(i);
//			boolean contains_additive = containsAdditive(pe);
//			if(last_additive&&!contains_additive) {
//				batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//			}
//			last_additive = contains_additive;
			
			pe.draw(batch);
		}
		
		batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
		
	}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:18,代码来源:ParticleSystem.java

示例4: update

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public void update(float delta) {
	for (int i = 0; i < effects.size; i++) {
		GameObject o = effects.getKeyAt(i);
		ParticleController pc = o.getController(ParticleController.class);
		PooledEffect pe = effects.getValueAt(i);
		if (pc.isComplete())
			pe.allowCompletion();
		pos_check.set((getLayer().getX() / cam.getZoom() + o.getAbsoluteX() + pc.getRelativeX()) * cam.getZoom(),
				(getLayer().getY() / cam.getZoom() + o.getAbsoluteY() + pc.getRelativeY()) * cam.getZoom());
		// cam.unproject(pos_check);
		pe.update(delta);
		if (cam.getZoom() != last_zoom) {
			float zoom_dif = last_zoom - cam.getZoom();
			pe.scaleEffect(1f - zoom_dif, 1f - zoom_dif, 1f - zoom_dif);
			last_zoom = cam.getZoom();
		}
		pre_draws.sort(pcomp);
		post_draws.sort(pcomp);
		pe.setPosition(pos_check.x, pos_check.y);
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:23,代码来源:ParticleSystem.java

示例5: updateAndRender

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
public void updateAndRender(float delta, Batch batch) {
  for (Entry<PooledEffect, GameObject> effectEntry : objects.entrySet()) {
    float x = effectEntry.getValue().getLeft() + offsets.get(effectEntry.getValue()).x;
    float y = effectEntry.getValue().getTop() + offsets.get(effectEntry.getValue()).y;
    effectEntry.getKey().setPosition(x, y);
    effectEntry.getKey().draw(batch, delta);
    if (effectEntry.getKey().isComplete()) {
      effectEntry.getKey().reset();
      remove(effectEntry.getKey());
      break;
    }
  }
  for (PooledEffect single : singleEffects) {
    single.draw(batch, delta);
    if (single.isComplete()) {
      single.free();
      singleEffects.remove(single);
    }
  }
}
 
开发者ID:bitbrain,项目名称:clouboy,代码行数:21,代码来源:ParticleRenderer.java

示例6: render

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public void render(float delta) {

    // TODO: Make this UDACITY_BLUE instead
    clearScreen(UDACITY_ORANGE);

    batch.begin();
    batch.draw(logo,
            (Gdx.graphics.getWidth() - LOGO_WIDTH) / 2,
            (Gdx.graphics.getHeight() - logoHeight) / 2,
            LOGO_WIDTH,
            logoHeight);
    for (int i = effects.size - 1; i >= 0; i--) {
        PooledEffect effect = effects.get(i);
        effect.draw(batch, delta);
        if (effect.isComplete()) {
            effect.free();
            effects.removeIndex(i);
        }
    }
    batch.end();
}
 
开发者ID:udacity,项目名称:ud405,代码行数:23,代码来源:UdacityScreen.java

示例7: render

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public void render(float delta) {
    clearScreen(UDACITY_ORANGE);
    batch.begin();
    // TODO: Investigate the .draw() method on SpriteBatch
    batch.draw(logo,
            (Gdx.graphics.getWidth() - LOGO_WIDTH) / 2,
            (Gdx.graphics.getHeight() - logoHeight) / 2,
            LOGO_WIDTH,
            logoHeight);
    // TODO: Why are we iterating backwards?
    for (int i = effects.size - 1; i >= 0; i--) {
        PooledEffect effect = effects.get(i);
        effect.draw(batch, delta);
        if (effect.isComplete()) {
            effect.free();
            effects.removeIndex(i);
        }
    }
    batch.end();
}
 
开发者ID:udacity,项目名称:ud406,代码行数:22,代码来源:UdacityScreen.java

示例8: addEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
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);
}
 
开发者ID:tjumyk,项目名称:touhou-java,代码行数:18,代码来源:ParticleScreen.java

示例9: invokeEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
/**
 * Invoke effect for special effect by its key. Change the current active key by key input parameter
 * @param x position-x of location where the effect happen.
 * @param y position-y of location where the effect happen.
 * @param key key for special effect
 */
public void invokeEffect(String key, float x, float y) {
	
	PooledEffect effect = collection.get(key).obtain();
	effect.setPosition(x, y);
	effects.add(effect);
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:13,代码来源:ParticleEffectManager.java

示例10: render

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public void render(float gameTime) {
	for (int i = effects.size - 1; i >= 0; i--) {
        PooledEffect effect = effects.get(i);
        effect.draw(getGameService().getSpriteBatch(), gameTime);
        if (effect.isComplete()) {
                effect.free();
                effects.removeIndex(i);
        }
	}
}
 
开发者ID:game-libgdx-unity,项目名称:GDX-Engine,代码行数:12,代码来源:ParticleEffectManager.java

示例11: getEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
public PooledEffect getEffect(String name) {
	if (particle_effects.containsKey(name)) {
		return particle_effects.get(name).obtain();
	}
	error("ParticleEffect -> not found [" + name + "].");
	return null;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:8,代码来源:GameState.java

示例12: init

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@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();
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:11,代码来源:ParticleSystem.java

示例13: gameObjectRemoved

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public void gameObjectRemoved(GameObject object, GameObject parent) {
	if (effects.containsKey(object)) {
		PooledEffect pe = effects.get(object);
		effects.removeKey(object);
		pre_draws.removeValue(pe, true);
		post_draws.removeValue(pe, true);
		pe.free();
	}
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:11,代码来源:ParticleSystem.java

示例14: containsAdditive

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
private static boolean containsAdditive(PooledEffect effect) {
	boolean additive = false;
	Array<ParticleEmitter> emmiters = effect.getEmitters();
	for (int i = 0; i < emmiters.size; i++) {
		if (emmiters.get(i).isAdditive()) {
			additive = true;
			break;
		}
	}
	return additive;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:12,代码来源:ParticleSystem.java

示例15: compare

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect; //导入依赖的package包/类
@Override
public int compare(PooledEffect o1, PooledEffect o2) {
	boolean o1_add = false;
	boolean o2_add = false;
	o1_add = containsAdditive(o1);
	o2_add = containsAdditive(o2);
	if (o1_add && !o2_add)
		return 11;
	else if (o2_add && !o1_add)
		return -1;
	return 0;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:13,代码来源:ParticleSystem.java


注:本文中的com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。