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