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


Java ParticleEmitter.draw方法代码示例

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


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

示例1: render

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入方法依赖的package包/类
public void render () {
	int viewWidth = Gdx.graphics.getWidth();
	int viewHeight = Gdx.graphics.getHeight();

	float delta = Math.max(0, Gdx.graphics.getDeltaTime() * deltaMultiplier.getValue());

	float[] colors = backgroundColor.getColors();
	Gdx.gl.glClearColor(colors[0], colors[1], colors[2], 1.0f);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	if ((pixelsPerMeter.getValue() != pixelsPerMeterPrev) || (zoomLevel.getValue() != zoomLevelPrev)) {
		if (pixelsPerMeter.getValue() <= 0) {
			pixelsPerMeter.setValue(1);
		}

		worldCamera.setToOrtho(false, viewWidth / pixelsPerMeter.getValue(), viewHeight / pixelsPerMeter.getValue());
		worldCamera.zoom = zoomLevel.getValue();
		worldCamera.update();
		effect.setPosition(worldCamera.viewportWidth / 2, worldCamera.viewportHeight / 2);
		zoomLevelPrev = zoomLevel.getValue();
		pixelsPerMeterPrev = pixelsPerMeter.getValue();
	}
	
	spriteBatch.setProjectionMatrix(worldCamera.combined);

	spriteBatch.begin();
	spriteBatch.enableBlending();
	spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

	if (bgImage != null) {
		bgImage.setPosition(viewWidth / 2 - bgImage.getWidth() / 2, viewHeight / 2 - bgImage.getHeight() / 2);
		bgImage.draw(spriteBatch);
	}

	activeCount = 0;
	boolean complete = true;
	for (ParticleEmitter emitter : effect.getEmitters()) {
		if (emitter.getSprite() == null && emitter.getImagePath() != null) loadImage(emitter);
		boolean enabled = isEnabled(emitter);
		if (enabled) {
			if (emitter.getSprite() != null) emitter.draw(spriteBatch, delta);
			activeCount += emitter.getActiveCount();
			if (!emitter.isComplete()) complete = false;
		}
	}
	if (complete) effect.start();

	maxActive = Math.max(maxActive, activeCount);
	maxActiveTimer += delta;
	if (maxActiveTimer > 3) {
		maxActiveTimer = 0;
		lastMaxActive = maxActive;
		maxActive = 0;
	}

	if (mouseDown) {
		// gl.drawLine(mouseX - 6, mouseY, mouseX + 5, mouseY);
		// gl.drawLine(mouseX, mouseY - 5, mouseX, mouseY + 6);
	}

	spriteBatch.setProjectionMatrix(textCamera.combined);

	font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 5, 15);
	font.draw(spriteBatch, "Count: " + activeCount, 5, 35);
	font.draw(spriteBatch, "Max: " + lastMaxActive, 5, 55);
	font.draw(spriteBatch, (int)(getEmitter().getPercentComplete() * 100) + "%", 5, 75);

	spriteBatch.end();

	// gl.drawLine((int)(viewWidth * getCurrentParticles().getPercentComplete()), viewHeight - 1, viewWidth, viewHeight -
	// 1);
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:73,代码来源:ParticleEditor.java

示例2: render

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入方法依赖的package包/类
@Override
public void render () {
	int viewWidth = Gdx.graphics.getWidth();
	int viewHeight = Gdx.graphics.getHeight();

	float delta = Math.max(0, Gdx.graphics.getDeltaTime() * this.particlePanel.deltaMultiplier.getValue());

	Gdx.gl.glClear(GL11.GL_COLOR_BUFFER_BIT);

	if ((this.particlePanel.pixelsPerMeter.getValue() != this.particlePanel.pixelsPerMeterPrev) || (this.particlePanel.zoomLevel.getValue() != this.particlePanel.zoomLevelPrev)) {
		if (this.particlePanel.pixelsPerMeter.getValue() <= 0) {
			this.particlePanel.pixelsPerMeter.setValue(1);
		}

		this.particlePanel.worldCamera.setToOrtho(false, viewWidth / this.particlePanel.pixelsPerMeter.getValue(), viewHeight / this.particlePanel.pixelsPerMeter.getValue());
		this.particlePanel.worldCamera.zoom = this.particlePanel.zoomLevel.getValue();
		this.particlePanel.worldCamera.update();
		this.particlePanel.effect.setPosition(this.particlePanel.worldCamera.viewportWidth / 2, this.particlePanel.worldCamera.viewportHeight / 2);
		this.particlePanel.zoomLevelPrev = this.particlePanel.zoomLevel.getValue();
		this.particlePanel.pixelsPerMeterPrev = this.particlePanel.pixelsPerMeter.getValue();
	}
	
	spriteBatch.setProjectionMatrix(this.particlePanel.worldCamera.combined);

	spriteBatch.begin();
	spriteBatch.enableBlending();
	spriteBatch.setBlendFunction(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

	if (bgImage != null) {
		bgImage.setPosition(viewWidth / 2 - bgImage.getWidth() / 2, viewHeight / 2 - bgImage.getHeight() / 2);
		bgImage.draw(spriteBatch);
	}

	activeCount = 0;
	boolean complete = true;
	for (ParticleEmitter emitter : this.particlePanel.effect.getEmitters()) {
		if (emitter.getSprite() == null && emitter.getImagePath() != null) loadImage(emitter);
		boolean enabled = this.particlePanel.isEnabled(emitter);
		if (enabled) {
			if (emitter.getSprite() != null) emitter.draw(spriteBatch, delta);
			activeCount += emitter.getActiveCount();
			if (!emitter.isComplete()) complete = false;
		}
	}
	if (complete) this.particlePanel.effect.start();

	maxActive = Math.max(maxActive, activeCount);
	maxActiveTimer += delta;
	if (maxActiveTimer > 3) {
		maxActiveTimer = 0;
		lastMaxActive = maxActive;
		maxActive = 0;
	}

	if (mouseDown) {
		// gl.drawLine(mouseX - 6, mouseY, mouseX + 5, mouseY);
		// gl.drawLine(mouseX, mouseY - 5, mouseX, mouseY + 6);
	}

	spriteBatch.setProjectionMatrix(this.particlePanel.textCamera.combined);

	font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 5, 15);
	font.draw(spriteBatch, "Count: " + activeCount, 5, 35);
	font.draw(spriteBatch, "Max: " + lastMaxActive, 5, 55);
	font.draw(spriteBatch, (int)(this.particlePanel.getEmitter().getPercentComplete() * 100) + "%", 5, 75);

	spriteBatch.end();

	// gl.drawLine((int)(viewWidth * getCurrentParticles().getPercentComplete()), viewHeight - 1, viewWidth, viewHeight -
	// 1);
}
 
开发者ID:pyros2097,项目名称:GdxStudio,代码行数:72,代码来源:ParticleRenderer.java

示例3: render

import com.badlogic.gdx.graphics.g2d.ParticleEmitter; //导入方法依赖的package包/类
public void render () {
	int viewWidth = Gdx.graphics.getWidth();
	int viewHeight = Gdx.graphics.getHeight();

	float delta = Gdx.graphics.getDeltaTime();

	Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

	if ((pixelsPerMeter.getValue() != pixelsPerMeterPrev) || (zoomLevel.getValue() != zoomLevelPrev)) {
		if (pixelsPerMeter.getValue() <= 0) {
			pixelsPerMeter.setValue(1);
		}

		worldCamera.setToOrtho(false, viewWidth / pixelsPerMeter.getValue(), viewHeight / pixelsPerMeter.getValue());
		worldCamera.zoom = zoomLevel.getValue();
		worldCamera.update();
		effect.setPosition(worldCamera.viewportWidth / 2, worldCamera.viewportHeight / 2);
		zoomLevelPrev = zoomLevel.getValue();
		pixelsPerMeterPrev = pixelsPerMeter.getValue();
	}

	spriteBatch.setProjectionMatrix(worldCamera.combined);

	spriteBatch.begin();
	spriteBatch.enableBlending();
	spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

	if (bgImage != null) {
		bgImage.setPosition(viewWidth / 2 - bgImage.getWidth() / 2, viewHeight / 2 - bgImage.getHeight() / 2);
		bgImage.draw(spriteBatch);
	}

	activeCount = 0;
	boolean complete = true;
	for (ParticleEmitter emitter : effect.getEmitters()) {
		if (emitter.getSprite() == null && emitter.getImagePath() != null) loadImage(emitter);
		boolean enabled = isEnabled(emitter);
		if (enabled) {
			if (emitter.getSprite() != null) emitter.draw(spriteBatch, delta);
			activeCount += emitter.getActiveCount();
			if (!emitter.isComplete()) complete = false;
		}
	}
	if (complete) effect.start();

	maxActive = Math.max(maxActive, activeCount);
	maxActiveTimer += delta;
	if (maxActiveTimer > 3) {
		maxActiveTimer = 0;
		lastMaxActive = maxActive;
		maxActive = 0;
	}

	if (mouseDown) {
		// gl.drawLine(mouseX - 6, mouseY, mouseX + 5, mouseY);
		// gl.drawLine(mouseX, mouseY - 5, mouseX, mouseY + 6);
	}

	spriteBatch.setProjectionMatrix(textCamera.combined);

	font.draw(spriteBatch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 5, 15);
	font.draw(spriteBatch, "Count: " + activeCount, 5, 35);
	font.draw(spriteBatch, "Max: " + lastMaxActive, 5, 55);
	font.draw(spriteBatch, (int)(getEmitter().getPercentComplete() * 100) + "%", 5, 75);

	spriteBatch.end();

	// gl.drawLine((int)(viewWidth * getCurrentParticles().getPercentComplete()), viewHeight - 1, viewWidth, viewHeight -
	// 1);
}
 
开发者ID:tjumyk,项目名称:touhou-java,代码行数:71,代码来源:ParticleEditor.java


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