當前位置: 首頁>>代碼示例>>Java>>正文


Java ParticleEffect.getEmitters方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.ParticleEffect.getEmitters方法的典型用法代碼示例。如果您正苦於以下問題:Java ParticleEffect.getEmitters方法的具體用法?Java ParticleEffect.getEmitters怎麽用?Java ParticleEffect.getEmitters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.graphics.g2d.ParticleEffect的用法示例。


在下文中一共展示了ParticleEffect.getEmitters方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public void addEffect(String name, Vector2 position, float angle){
	logger.debug("Creating effect: " + name);
	ParticleEffect effect = App.assets.getEffect(name);
	if (effect == null) {
		logger.error("Couldn't create particle effect: " + name);
		return;
	}
	ParticleEffect e = new ParticleEffect(effect);
	for (ParticleEmitter emitter : e.getEmitters()){
		float a1 = emitter.getAngle().getHighMin(),
			  a2 = emitter.getAngle().getHighMax();
		
		emitter.getRotation().setHighMin(a1 + angle);
		emitter.getRotation().setHighMax(a2 + angle);
	}
	e.setPosition(position.x * App.engine.PIXELS_PER_METER, position.y * App.engine.PIXELS_PER_METER);
	e.start();
	effects.add(e);
	
}
 
開發者ID:Deftwun,項目名稱:ZombieCopter,代碼行數:21,代碼來源:ParticleSystem.java

示例2: addParticle

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
/**
 * Adds a ParticleEffect from a ParticleEffectVO. Uses ParticleEmitterBox2D
 * @param item ParticleEffectVO to add
 */
private static void addParticle(ParticleEffectVO item) {
    ParticleEffect particleEffect = new ParticleEffect();
    particleEffect.load(Gdx.files.internal(particlesPath + "/" + item.particleName), atlas);
    particleEffect.scaleEffect(ZeroBit.pixelsToMeters * item.scaleX);

    for (int i=0; i < particleEffect.getEmitters().size; i++) {
        particleEffect.getEmitters().set(i, new ParticleEmitterBox2D(b2dSystem.getB2World(), particleEffect.getEmitters().get(i)));
        ParticleEmitter emitter = particleEffect.getEmitters().get(i);

        // Spawn scaling doesn't seem to alter the actual dimensions of the effect like in the editor
        /*emitter.getSpawnWidth().setHigh(emitter.getSpawnWidth().getHighMin() * item.scaleX, emitter.getSpawnWidth().getHighMax() * item.scaleX);
        emitter.getSpawnWidth().setLow(emitter.getSpawnWidth().getLowMin() * item.scaleX, emitter.getSpawnWidth().getLowMax() * item.scaleX);
        emitter.getSpawnHeight().setHigh(emitter.getSpawnHeight().getHighMin() * item.scaleY, emitter.getSpawnHeight().getHighMax() * item.scaleY);
        emitter.getSpawnHeight().setLow(emitter.getSpawnHeight().getLowMin() * item.scaleY, emitter.getSpawnHeight().getLowMax() * item.scaleY);*/

        emitter.setPosition(item.x * ZeroBit.pixelsToMeters, item.y * ZeroBit.pixelsToMeters);
    }
    //entityManager.getEngine().getSystem(RenderingSystem.class).addParticle(particleEffect);
    ParticleComponent pc = new ParticleComponent();
    pc.addParticle(particleEffect);
    addEntity(item, null, pc, new VisualComponent());
}
 
開發者ID:ALPSquid,項目名稱:0Bit-Engine,代碼行數:27,代碼來源:Overlap2DLoader.java

示例3: setAlpha

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
@Override
public void setAlpha(float alpha) {

  // TODO: Alpha doesn't work for particles here as intended :(

  this.alpha = alpha;

  for (ParticleEffect e : effects.keySet()) {

    for (ParticleEmitter emitter : e.getEmitters()) {
      ScaledNumericValue v = emitter.getTransparency();
      v.setHigh(alpha);
      v.setLow(alpha);
    }
  }
}
 
開發者ID:bitbrain,項目名稱:craft,代碼行數:17,代碼來源:ParticleRenderer.java

示例4: onRemoveTrailColor

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
@Override
public void onRemoveTrailColor(MonsterColor color) {
	
	Maze maze = color.getMonster().getMaze();
	ParticleEffect effect = manager.create(Assets.getInstance().get(Assets.FLARE, ParticleEffect.class), false);
	float x = color.getX() * maze.getBlockSize() + maze.getX() + maze.getBlockSize() / 2;
	float y = color.getY() * maze.getBlockSize() + maze.getY() + maze.getBlockSize() / 2;
	
	effect.setPosition(x, y);

	manager.setColor(effect, new float[]{color.r, color.g, color.b}, new float[]{0f});
	effect.start();
	
	for (ParticleEmitter e : effect.getEmitters()) {
		e.getScale().setLow(Gdx.graphics.getWidth() / 30f);
		e.getDuration().setLow(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 104);
		e.getLife().setLow(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 140);
		e.getDuration().setLowMin(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 140);
		e.getLife().setLowMin(Monster.LENGTH * StupidMonsterLogic.INTERVAL / 140);
		e.getVelocity().setLow(Gdx.graphics.getWidth() / 50f);
	}
	
	effects.put(color, effect);
	
	Gdx.input.vibrate(20);
}
 
開發者ID:bitbrain,項目名稱:maze,代碼行數:27,代碼來源:GameParticleHandler.java

示例5: resetFireworksEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
/**
 * Resets the position, start color and duration of the given firework effects to random values.
 *
 * @param effect
 */
private void resetFireworksEffect(ParticleEffect effect) {
    effect.reset();
    effect.setDuration(Utils.randomWithin(180, 250));
    effect.setPosition(Utils.randomWithin(0, WINDOW_WIDTH), Utils.randomWithin(0, WINDOW_HEIGHT));
    float[] colors = effect.getEmitters().get(0).getTint().getColors();
    int randomStartColor = Utils.randomWithin(0, startColors.length - 1);
    for (int i = 0; i < 6; i++) {
        colors[i] = startColors[randomStartColor][i % 3];
    }
    for (ParticleEmitter emitter : effect.getEmitters()) {
        emitter.getTint().setColors(colors);
    }
}
 
開發者ID:cdetamble,項目名稱:jewelthief,代碼行數:19,代碼來源:Particles.java

示例6: getEmittersByName

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
/**
 * Returns all emitters from the supplied effect with a name 
 * that starts with the supplied prefix.
 * 
 * Case insensitive.
 * 
 * @param pe
 * @param prefix
 * @return
 */
public static Array<ParticleEmitter> getEmittersByName(ParticleEffect pe, String prefix) {
	prefix = prefix.toLowerCase(Locale.ENGLISH);
	Array<ParticleEmitter> returnValue = new  Array<ParticleEmitter>();
	for (ParticleEmitter p : pe.getEmitters()) {
		if (p.getName().toLowerCase(Locale.ENGLISH).startsWith(prefix)) {
			returnValue.add(p);
		}
	}
	return returnValue;
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:21,代碼來源:GraphicsUtil.java

示例7: rotate

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
/**
 * Rotates the supplied particle effect by setting
 * the angle value of all emitters to the supplied value.
 * 
 * The first emitter is rotated to the supplied value
 * and the others are then rotated relatively to the first one.
 * 
 * @param pe
 * @param angle the new angle, in degrees
 */
public static void rotate(ParticleEffect pe, float angle) {
	boolean first = true;
	float firstHighMax = 0, firstHighMin = 0, firstLowMax = 0, firstLowMin = 0;
	for (ParticleEmitter e : pe.getEmitters()) {
		if (first) {
			firstHighMin = e.getAngle().getHighMin();
			firstHighMax = e.getAngle().getHighMax();
			firstLowMax = e.getAngle().getLowMax();
			firstLowMin = e.getAngle().getLowMin();
			
			e.getAngle().setHighMax(angle); 
		    e.getAngle().setHighMin(angle - (firstHighMax-firstHighMin)); 
		    e.getAngle().setLowMax(angle - (firstHighMax-firstLowMax));
		    e.getAngle().setLowMin(angle - (firstHighMax-firstLowMin));
		   
		    first = false;
		} else {
			float oldAngle = e.getAngle().getHighMax();
			e.getAngle().setHighMax(angle - (firstHighMax-oldAngle)); 
			oldAngle = e.getAngle().getHighMin();
		    e.getAngle().setHighMin(angle - (firstHighMin-oldAngle));
		    oldAngle = e.getAngle().getLowMax();
		    e.getAngle().setLowMax(angle - (firstLowMax-oldAngle));
		    oldAngle = e.getAngle().getLowMin();
		    e.getAngle().setLowMin(angle - (firstLowMin-oldAngle));
		}
	}
}
 
開發者ID:mganzarcik,項目名稱:fabulae,代碼行數:39,代碼來源:GraphicsUtil.java

示例8: openEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
void openEffect () {
	FileDialog dialog = new FileDialog(editor, "Open Effect", FileDialog.LOAD);
	if (lastDir != null) dialog.setDirectory(lastDir);
	dialog.setVisible(true);
	final String file = dialog.getFile();
	final String dir = dialog.getDirectory();
	if (dir == null || file == null || file.trim().length() == 0) return;
	lastDir = dir;
	ParticleEffect effect = new ParticleEffect();
	try {
		effect.loadEmitters(Gdx.files.absolute(new File(dir, file).getAbsolutePath()));
		editor.effect = effect;
		emitterTableModel.getDataVector().removeAllElements();
		editor.particleData.clear();
	} catch (Exception ex) {
		System.out.println("Error loading effect: " + new File(dir, file).getAbsolutePath());
		ex.printStackTrace();
		JOptionPane.showMessageDialog(editor, "Error opening effect.");
		return;
	}
	for (ParticleEmitter emitter : effect.getEmitters()) {
		emitter.setPosition(editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
		emitterTableModel.addRow(new Object[] {emitter.getName(), true});
	}
	editIndex = 0;
	emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
	editor.reloadRows();
}
 
開發者ID:basherone,項目名稱:libgdxcn,代碼行數:29,代碼來源:EffectPanel.java

示例9: openEffect

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
void openEffect () {
	FileDialog dialog = new FileDialog((Frame) null, "Open Effect", FileDialog.LOAD);
	if (lastDir != null) dialog.setDirectory(lastDir);
	dialog.setVisible(true);
	final String file = dialog.getFile();
	final String dir = dialog.getDirectory();
	if (dir == null || file == null || file.trim().length() == 0) return;
	lastDir = dir;
	ParticleEffect effect = new ParticleEffect();
	try {
		effect.loadEmitters(Gdx.files.absolute(new File(dir, file).getAbsolutePath()));
		editor.effect = effect;
		emitterTableModel.getDataVector().removeAllElements();
		editor.particleData.clear();
	} catch (Exception ex) {
		System.out.println("Error loading effect: " + new File(dir, file).getAbsolutePath());
		ex.printStackTrace();
		JOptionPane.showMessageDialog(editor, "Error opening effect.");
		return;
	}
	for (ParticleEmitter emitter : effect.getEmitters()) {
		emitter.setPosition(editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
		emitterTableModel.addRow(new Object[] {emitter.getName(), true});
	}
	editIndex = 0;
	emitterTable.getSelectionModel().setSelectionInterval(editIndex, editIndex);
	editor.reloadRows();
}
 
開發者ID:pyros2097,項目名稱:GdxStudio,代碼行數:29,代碼來源:EffectPanel.java

示例10: getParticleCount

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public int getParticleCount(ParticleEffect effect) {
	
	int count = 0;
	
	for (ParticleEmitter emitter : effect.getEmitters()) {
		if (count < emitter.getMaxParticleCount()) {
			count = emitter.getMaxParticleCount();
		}
	}
	
	return count;
}
 
開發者ID:bitbrain,項目名稱:plox,代碼行數:13,代碼來源:ParticleManager.java

示例11: setEndless

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public void setEndless(ParticleEffect effect, boolean endless) {
	
	if (effect != null) {
		effects.put(effect, endless);
		
		for (ParticleEmitter emitter : effect.getEmitters()) {
			emitter.setContinuous(endless);
		}
	}
}
 
開發者ID:bitbrain,項目名稱:plox,代碼行數:11,代碼來源:ParticleManager.java

示例12: getParticleCount

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public int getParticleCount(ParticleEffect effect) {

    int count = 0;

    for (ParticleEmitter emitter : effect.getEmitters()) {
      if (count < emitter.getMaxParticleCount()) {
        count = emitter.getMaxParticleCount();
      }
    }

    return count;
  }
 
開發者ID:bitbrain,項目名稱:craft,代碼行數:13,代碼來源:ParticleRenderer.java

示例13: setEndless

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public void setEndless(ParticleEffect effect, boolean endless) {

    if (effect != null) {
      effects.put(effect, endless);

      for (ParticleEmitter emitter : effect.getEmitters()) {
        emitter.setContinuous(endless);
      }
    }
  }
 
開發者ID:bitbrain,項目名稱:craft,代碼行數:11,代碼來源:ParticleRenderer.java

示例14: getParticleCount

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public int getParticleCount(ParticleEffect effect) {
        
        int count = 0;
        
        for (ParticleEmitter emitter : effect.getEmitters()) {
                if (count < emitter.getMaxParticleCount()) {
                        count = emitter.getMaxParticleCount();
                }
        }
        
        return count;
}
 
開發者ID:bitbrain,項目名稱:maze,代碼行數:13,代碼來源:ParticleManager.java

示例15: setEndless

import com.badlogic.gdx.graphics.g2d.ParticleEffect; //導入方法依賴的package包/類
public void setEndless(ParticleEffect effect, boolean endless) {
        
        if (effect != null) {
                effects.put(effect, endless);
                
                for (ParticleEmitter emitter : effect.getEmitters()) {
                        emitter.setContinuous(endless);
                }
        }
}
 
開發者ID:bitbrain,項目名稱:maze,代碼行數:11,代碼來源:ParticleManager.java


注:本文中的com.badlogic.gdx.graphics.g2d.ParticleEffect.getEmitters方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。