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


Java ParticleEmitter类代码示例

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


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

示例1: widen

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
/**
 * Widens the emission angle of the supplied emitters
 * by the supplied coefficient. 
 * 
 * @param pe
 * @param coef
 */
public static void widen(Array<ParticleEmitter> emitters, float coef) {
	for (ParticleEmitter e : emitters) {
		float highMin = e.getAngle().getHighMin();
		float highMax = e.getAngle().getHighMax();
		
		float oldDist = (highMax - highMin);
		float newDist =  oldDist * coef;
		float distDif = newDist - oldDist;
		
		e.getAngle().setHighMax(highMax + distDif / 2); 
	    e.getAngle().setHighMin(highMin - distDif / 2); 
		
		float lowMin = e.getAngle().getLowMin();
		float lowMax = e.getAngle().getLowMax();
		
		oldDist = (lowMax - lowMin);
		newDist =  oldDist * coef;
		distDif = newDist - oldDist;
	    
	    e.getAngle().setLowMax(lowMax + distDif / 2);
	    e.getAngle().setLowMin(lowMin - distDif / 2);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:31,代码来源:GraphicsUtil.java

示例2: update

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
@Override
public void update(float deltaTime) {
	if (attachedObj != null) {
		setPosition(attachedObj.getX() + objOffsetX, attachedObj.getY() + objOffsetY);
	}

	if (loopPosition > 0) {
		for (ParticleEmitter emitter : getEmitters()) {
			if (emitter.durationTimer > loopPosition) {
				emitter.durationTimer = loopPosition;
			}
		}
	}

	super.update(deltaTime);
}
 
开发者ID:Quillraven,项目名称:Protoman-vs-Megaman,代码行数:17,代码来源:ParticleFX.java

示例3: addEffect

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的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

示例4: getIcon

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
public ImageIcon getIcon (ParticleEmitter emitter) {
	ParticleData data = particleData.get(emitter);
	if (data == null) particleData.put(emitter, data = new ParticleData());
	String imagePath = emitter.getImagePath();
	if (data.icon == null && imagePath != null) {
		try {
			URL url;
			File file = new File(imagePath);
			if (file.exists())
				url = file.toURI().toURL();
			else {
				url = ParticleEditor.class.getResource(imagePath);
				if (url == null) return null;
			}
			data.icon = new ImageIcon(url);
		} catch (MalformedURLException ex) {
			ex.printStackTrace();
		}
	}
	return data.icon;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:ParticleEditor.java

示例5: loadImage

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
private void loadImage (ParticleEmitter emitter) {
	final String imagePath = emitter.getImagePath();
	String imageName = new File(imagePath.replace('\\', '/')).getName();
	try {
		FileHandle file;
		if (imagePath.equals(ParticleEditor.DEFAULT_PARTICLE) || imagePath.equals(ParticleEditor.DEFAULT_PREMULT_PARTICLE))
			file = Gdx.files.classpath(imagePath);
		else
			file = Gdx.files.absolute(imagePath);
		emitter.setSprite(new Sprite(new Texture(file)));
	} catch (GdxRuntimeException ex) {
		ex.printStackTrace();
		EventQueue.invokeLater(new Runnable() {
			public void run () {
				JOptionPane.showMessageDialog(ParticleEditor.this, "Error loading image:\n" + imagePath);
			}
		});
		emitter.setImagePath(null);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:21,代码来源:ParticleEditor.java

示例6: newEmitter

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
public ParticleEmitter newEmitter (String name, boolean select) {
	final ParticleEmitter emitter = new ParticleEmitter();

	emitter.getDuration().setLow(1000);
	emitter.getEmission().setHigh(50);
	emitter.getLife().setHigh(500);
	emitter.getScale().setHigh(32, 32);

	emitter.getTint().setColors(new float[] {1, 0.12156863f, 0.047058824f});
	emitter.getTransparency().setHigh(1);

	emitter.setMaxParticleCount(25);
	emitter.setImagePath(ParticleEditor.DEFAULT_PARTICLE);

	addEmitter(name, select, emitter);
	return emitter;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:EffectPanel.java

示例7: addEmitter

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
private void addEmitter (String name, boolean select, final ParticleEmitter emitter) {
	Array<ParticleEmitter> emitters = editor.effect.getEmitters();
	if (emitters.size == 0)
		emitter.setPosition(editor.worldCamera.viewportWidth / 2, editor.worldCamera.viewportHeight / 2);
	else {
		ParticleEmitter p = emitters.get(0);
		emitter.setPosition(p.getX(), p.getY());
	}
	emitters.add(emitter);

	emitterTableModel.addRow(new Object[] {name, true});
	if (select) {
		editor.reloadRows();
		int row = emitterTableModel.getRowCount() - 1;
		emitterTable.getSelectionModel().setSelectionInterval(row, row);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:18,代码来源:EffectPanel.java

示例8: saveEffect

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
void saveEffect () {
	FileDialog dialog = new FileDialog(editor, "Save Effect", FileDialog.SAVE);
	if (lastDir != null) dialog.setDirectory(lastDir);
	dialog.setVisible(true);
	String file = dialog.getFile();
	String dir = dialog.getDirectory();
	if (dir == null || file == null || file.trim().length() == 0) return;
	lastDir = dir;
	int index = 0;
	for (ParticleEmitter emitter : editor.effect.getEmitters())
		emitter.setName((String)emitterTableModel.getValueAt(index++, 0));

	File outputFile = new File(dir, file);
	Writer fileWriter = null;
	try {
		fileWriter = new FileWriter(outputFile);
		editor.effect.save(fileWriter);
	} catch (Exception ex) {
		System.out.println("Error saving effect: " + outputFile.getAbsolutePath());
		ex.printStackTrace();
		JOptionPane.showMessageDialog(editor, "Error saving effect.");
	} finally {
		StreamUtils.closeQuietly(fileWriter);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:EffectPanel.java

示例9: resetEffect

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
public void resetEffect() {
	stopped = false;
	playbackTime = 0f;
	playbackDuration = 1f + Random.randomInt(1.75f, 4.5f);

	activeEffect.setPosition(Random.randomInt(worldBounds.x, worldBounds.width + 1), Random.randomInt(worldBounds.y, worldBounds.height + 1));

	for (ParticleEmitter emitter : activeEffect.getEmitters()) {
		emitter.reset();

		if (!emitter.getName().contains("smoke")) {
			emitter.getTint().setColors(colorsIterator.next());
		}
	}

}
 
开发者ID:frigidplanet,项目名称:droidtowers,代码行数:17,代码来源:ParticleEffectManager.java

示例10: getIcon

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
public ImageIcon getIcon (ParticleEmitter emitter) {
	ParticleData data = particleData.get(emitter);
	if (data == null) particleData.put(emitter, data = new ParticleData());
	String imagePath = emitter.getImagePath();
	if (data.icon == null && imagePath != null) {
		try {
			URL url;
			File file = new File(imagePath);
			if (file.exists())
				url = file.toURI().toURL();
			else {
				url = ParticlePanel.class.getResource(imagePath);
				if (url == null) return null;
			}
			data.icon = new ImageIcon(url);
		} catch (MalformedURLException ex) {
			ex.printStackTrace();
		}
	}
	return data.icon;
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:22,代码来源:ParticlePanel.java

示例11: newEmitter

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
public ParticleEmitter newEmitter (String name, boolean select) {
	final ParticleEmitter emitter = new ParticleEmitter();

	emitter.getDuration().setLow(1000);
	emitter.getEmission().setHigh(50);
	emitter.getLife().setHigh(500);
	emitter.getScale().setHigh(32, 32);

	emitter.getTint().setColors(new float[] {1, 0.12156863f, 0.047058824f});
	emitter.getTransparency().setHigh(1);

	emitter.setFlip(false, true);
	emitter.setMaxParticleCount(25);
	emitter.setImagePath("particle.png");

	addEmitter(name, select, emitter);
	return emitter;
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:19,代码来源:EffectPanel.java

示例12: saveEffect

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
void saveEffect () {
	FileDialog dialog = new FileDialog((Frame) null, "Save Effect", FileDialog.SAVE);
	if (lastDir != null) dialog.setDirectory(lastDir);
	dialog.setVisible(true);
	String file = dialog.getFile();
	String dir = dialog.getDirectory();
	if (dir == null || file == null || file.trim().length() == 0) return;
	lastDir = dir;
	int index = 0;
	for (ParticleEmitter emitter : editor.effect.getEmitters())
		emitter.setName((String)emitterTableModel.getValueAt(index++, 0));
	try {
		editor.effect.save(new File(dir, file));
	} catch (Exception ex) {
		System.out.println("Error saving effect: " + new File(dir, file).getAbsolutePath());
		ex.printStackTrace();
		JOptionPane.showMessageDialog(editor, "Error saving effect.");
	}
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:20,代码来源:EffectPanel.java

示例13: loadImage

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的package包/类
private void loadImage (ParticleEmitter emitter) {
	final String imagePath = emitter.getImagePath();
	String imageName = new File(imagePath.replace('\\', '/')).getName();
	try {
		FileHandle file;
		if (imagePath.equals("particle.png"))
			file = Gdx.files.classpath(imagePath);
		else
			file = Gdx.files.absolute(imagePath);
		emitter.setSprite(new Sprite(new Texture(file)));
	} catch (GdxRuntimeException ex) {
		ex.printStackTrace();
		EventQueue.invokeLater(new Runnable() {
			public void run () {
				JOptionPane.showMessageDialog(ParticleRenderer.this.particlePanel, "Error loading image:\n" + imagePath);
			}
		});
		emitter.setImagePath(null);
	}
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:21,代码来源:ParticleRenderer.java

示例14: addParticle

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的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

示例15: setAlpha

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入依赖的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


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