本文整理汇总了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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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();
}
}
示例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;
}
示例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;
}