From 5d78777f63e354ef6b027fb79c1c038da3a6f3d7 Mon Sep 17 00:00:00 2001 From: "nathan.sweet" Date: Mon, 1 Nov 2010 10:30:17 +0000 Subject: [PATCH] [fixed] LwjglApplication had large first delta. [changed] ParticleEmitter to be slightly more efficient. Still no javadoc, I didn't forget. [changed] Sprite javadocs. Added empty constructor. --- .../gdx/backends/desktop/LwjglApplication.java | 1 + .../gdx/backends/desktop/LwjglGraphics.java | 5 +- .../gdx/graphics/particles/EffectPanel.java | 25 +++ .../com/badlogic/gdx/twl/tests/TextAreaTest.java | 1 + .../badlogic/gdx/graphics/OrthographicCamera.java | 1 - gdx/src/com/badlogic/gdx/graphics/Sprite.java | 33 +++- gdx/src/com/badlogic/gdx/graphics/SpriteBatch.java | 2 + .../gdx/graphics/particles/ParticleEffect.java | 11 +- .../gdx/graphics/particles/ParticleEmitter.java | 216 ++++++++++----------- 9 files changed, 168 insertions(+), 127 deletions(-) diff --git a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java index 847d9a349..657c0ed27 100644 --- a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java +++ b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglApplication.java @@ -177,6 +177,7 @@ import com.badlogic.gdx.utils.GdxRuntimeException; for (RenderListener listener : listeners) listener.surfaceCreated(); setSize(width, height); + graphics.lastTime = System.nanoTime(); for (RenderListener listener : listeners) listener.render(); diff --git a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java index afd147dd3..d73ba1a2d 100644 --- a/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java +++ b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/desktop/LwjglGraphics.java @@ -44,12 +44,13 @@ public final class LwjglGraphics implements Graphics, RenderListener { private GL11 gl11; private GL20 gl20; private final boolean useGL2; - private long lastTime; private float deltaTime = 0; private long frameStart = 0; private int frames = 0; private int fps; + long lastTime; + LwjglGraphics (final LwjglApplication application, String title, int width, int height, boolean useGL2IfAvailable) { this.app = application; useGL2 = useGL2IfAvailable; @@ -180,8 +181,6 @@ public final class LwjglGraphics implements Graphics, RenderListener { Gdx.gl10 = gl10; Gdx.gl11 = gl11; Gdx.gl20 = gl20; - - lastTime = System.nanoTime(); } public float getDeltaTime () { diff --git a/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/EffectPanel.java b/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/EffectPanel.java index 527e17286..8043e6c20 100644 --- a/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/EffectPanel.java +++ b/extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/EffectPanel.java @@ -40,6 +40,31 @@ class EffectPanel extends JPanel { public ParticleEmitter newEmitter (String name, boolean select) { final ParticleEmitter emitter = new ParticleEmitter(); + + emitter.getDuration().setLow(3000, 3000); + + emitter.getEmission().setHigh(10, 10); + + emitter.getLife().setHigh(1000, 1000); + + emitter.getScale().setHigh(32, 32); + + emitter.getRotation().setLow(1, 360); + emitter.getRotation().setHigh(180, 180); + emitter.getRotation().setTimeline(new float[] {0, 1}); + emitter.getRotation().setScaling(new float[] {0, 1}); + emitter.getRotation().setRelative(true); + + emitter.getAngle().setHigh(1, 360); + emitter.getAngle().setActive(true); + + emitter.getVelocity().setHigh(80, 80); + emitter.getVelocity().setActive(true); + + emitter.getTransparency().setHigh(1, 1); + emitter.getTransparency().setTimeline(new float[] {0, 0.2f, 0.8f, 1}); + emitter.getTransparency().setScaling(new float[] {0, 1, 1, 0}); + emitter.setFlip(false, true); emitter.setMaxParticleCount(15); emitter.setImagePath("data/particle.png"); diff --git a/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java b/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java index 33aa32448..c74b5090b 100644 --- a/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java +++ b/extensions/twl/gdx-twl-tests/src/com/badlogic/gdx/twl/tests/TextAreaTest.java @@ -64,6 +64,7 @@ public class TextAreaTest implements RenderListener { } if (timer.isRunning()) return; timer.start(); + System.out.println(); speed = -speed; } }); diff --git a/gdx/src/com/badlogic/gdx/graphics/OrthographicCamera.java b/gdx/src/com/badlogic/gdx/graphics/OrthographicCamera.java index 385c29c9e..2660a233f 100644 --- a/gdx/src/com/badlogic/gdx/graphics/OrthographicCamera.java +++ b/gdx/src/com/badlogic/gdx/graphics/OrthographicCamera.java @@ -147,7 +147,6 @@ public final class OrthographicCamera { */ public void update () { proj.setToOrtho2D(0, 0, (viewportWidth * scale), (viewportHeight * scale), near, far); - model.idt(); model.setToTranslation(tmp.set((-position.x + (viewportWidth / 2) * scale), (-position.y + (viewportHeight / 2) * scale), (-position.z))); combined.set(proj); diff --git a/gdx/src/com/badlogic/gdx/graphics/Sprite.java b/gdx/src/com/badlogic/gdx/graphics/Sprite.java index 03f50757b..f8c37d960 100644 --- a/gdx/src/com/badlogic/gdx/graphics/Sprite.java +++ b/gdx/src/com/badlogic/gdx/graphics/Sprite.java @@ -27,6 +27,13 @@ public class Sprite { private boolean dirty; /** + * Creates an uninitialized sprite. The sprite will need a texture, texture region, bounds, and color set before it can be + * drawn. + */ + public Sprite () { + } + + /** * Creates a sprite with width, height, and texture region equal to the size of the texture. */ public Sprite (Texture texture) { @@ -36,6 +43,8 @@ public class Sprite { /** * Creates a sprite with width, height, and texture region equal to the specified size. The texture region's upper left corner * will be 0,0. + * @param srcWidth The width of the texture region. May be negative to flip the sprite when drawn. + * @param srcHeight The height of the texture region. May be negative to flip the sprite when drawn. */ public Sprite (Texture texture, int srcWidth, int srcHeight) { this(texture, 0, 0, srcWidth, srcHeight); @@ -43,19 +52,23 @@ public class Sprite { /** * Creates a sprite with width, height, and texture region equal to the specified size. + * @param srcWidth The width of the texture region. May be negative to flip the sprite when drawn. + * @param srcHeight The height of the texture region. May be negative to flip the sprite when drawn. */ public Sprite (Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) { if (texture == null) throw new IllegalArgumentException("texture cannot be null."); this.texture = texture; setTextureRegion(srcX, srcY, srcWidth, srcHeight); setColor(1, 1, 1, 1); - setBounds(0, 0, Math.abs(srcWidth), Math.abs(srcHeight)); + setSize(Math.abs(srcWidth), Math.abs(srcHeight)); setOrigin(width / 2, height / 2); } /** * Creates a sprite with width, height, and texture region equal to the specified size, relative to specified sprite's texture * region. + * @param srcWidth The width of the texture region. May be negative to flip the sprite when drawn. + * @param srcHeight The height of the texture region. May be negative to flip the sprite when drawn. */ public Sprite (Sprite parent, int srcX, int srcY, int srcWidth, int srcHeight) { this(parent.texture, (int)(srcX + parent.vertices[U1] * parent.texture.getWidth()), (int)(srcY + parent.vertices[V2] @@ -63,8 +76,8 @@ public class Sprite { } /** - * Sets the size and position of the sprite when drawn, before scaling and rotation are applied. If origin, rotation, or scale - * are changed, it is slightly more efficient to set the bounds afterward. + * Sets the position and size of the sprite when drawn, before scaling and rotation are applied. If origin, rotation, or scale + * are changed, it is slightly more efficient to set the bounds after those operations. */ public void setBounds (float x, float y, float width, float height) { this.x = x; @@ -94,8 +107,8 @@ public class Sprite { /** * Sets the size of the sprite when drawn, before scaling and rotation are applied. If origin, rotation, or scale are changed, - * it is slightly more efficient to set the size afterward. If both position and size are to be changed, it is better to use - * {@link #setBounds(float, float, float, float)}. + * it is slightly more efficient to set the size after those operations. If both position and size are to be changed, it is + * better to use {@link #setBounds(float, float, float, float)}. */ public void setSize (float width, float height) { this.width = width; @@ -123,7 +136,7 @@ public class Sprite { /** * Sets the position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more efficient - * to set the position afterward. If both position and size are to be changed, it is better to use + * to set the position after those operations. If both position and size are to be changed, it is better to use * {@link #setBounds(float, float, float, float)}. */ public void setPosition (float x, float y) { @@ -132,7 +145,7 @@ public class Sprite { /** * Sets the position relative to the current position where the sprite will be drawn. If origin, rotation, or scale are - * changed, it is slightly more efficient to translate afterward. + * changed, it is slightly more efficient to translate after those operations. */ public void translate (float xAmount, float yAmount) { x += xAmount; @@ -155,7 +168,9 @@ public class Sprite { } /** - * Sets the texture coordinates in pixels to apply to the sprite. + * Sets the texture coordinates in pixels to apply to the sprite. This resets calling {@link #flip(boolean, boolean)}. + * @param srcWidth The width of the texture region. May be negative to flip the sprite when drawn. + * @param srcHeight The height of the texture region. May be negative to flip the sprite when drawn. */ public void setTextureRegion (int srcX, int srcY, int srcWidth, int srcHeight) { float invTexWidth = 1.0f / texture.getWidth(); @@ -192,7 +207,7 @@ public class Sprite { } /** - * Flips the texture. + * Flips the current texture region. */ public void flip (boolean x, boolean y) { float[] vertices = this.vertices; diff --git a/gdx/src/com/badlogic/gdx/graphics/SpriteBatch.java b/gdx/src/com/badlogic/gdx/graphics/SpriteBatch.java index 92539ccde..30d47ee44 100644 --- a/gdx/src/com/badlogic/gdx/graphics/SpriteBatch.java +++ b/gdx/src/com/badlogic/gdx/graphics/SpriteBatch.java @@ -200,6 +200,7 @@ public class SpriteBatch { * @param transform the transformation matrix. */ public void begin () { + if (drawing) throw new IllegalStateException("you have to call SpriteBatch.end() first"); renderCalls = 0; if (Gdx.graphics.isGL20Available() == false) { @@ -243,6 +244,7 @@ public class SpriteBatch { * Finishes off rendering of the last batch of sprites */ public void end () { + if (!drawing) throw new IllegalStateException("you have to call SpriteBatch.begin() first"); if (idx > 0) renderMesh(); lastTexture = null; idx = 0; diff --git a/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEffect.java b/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEffect.java index 043724123..44b3ebb68 100644 --- a/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEffect.java +++ b/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEffect.java @@ -14,12 +14,11 @@ import com.badlogic.gdx.Files.FileType; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.SpriteBatch; +import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.Texture.TextureWrap; import com.badlogic.gdx.utils.GdxRuntimeException; -// BOZO - Cache particle images? Or add hook to customize loading of particle images? - public class ParticleEffect { private ArrayList emitters = new ArrayList(); @@ -129,8 +128,12 @@ public class ParticleEffect { if (imagePath == null) continue; imagePath = imagePath.replace('\\', '/'); imagePath = imagesDir + new File(imagePath).getName(); - emitter.setTexture(Gdx.graphics.newTexture(Gdx.files.getFileHandle(imagePath, fileType), TextureFilter.Linear, - TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge)); + emitter.setTexture(loadTexture(Gdx.files.getFileHandle(imagePath, fileType))); } } + + protected Texture loadTexture (FileHandle file) { + return Gdx.graphics.newTexture(file, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge, + TextureWrap.ClampToEdge); + } } diff --git a/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEmitter.java b/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEmitter.java index d2910f267..d47bbc21e 100644 --- a/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEmitter.java +++ b/gdx/src/com/badlogic/gdx/graphics/particles/ParticleEmitter.java @@ -4,7 +4,6 @@ package com.badlogic.gdx.graphics.particles; import java.io.BufferedReader; import java.io.IOException; import java.io.Writer; -import java.math.BigInteger; import java.util.BitSet; import com.badlogic.gdx.graphics.GL10; @@ -13,7 +12,7 @@ import com.badlogic.gdx.graphics.SpriteBatch; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.utils.MathUtils; -// BOZO - Support point particles? +// BOZO - Javadoc. // BOZO - Add a duplicate emitter button. public class ParticleEmitter { @@ -57,9 +56,9 @@ public class ParticleEmitter { private boolean flipX, flipY; private int updateFlags; - private float emission, emissionDiff, emissionDelta; - private float lifeOffset, lifeOffsetDiff; - private float life, lifeDiff; + private int emission, emissionDiff, emissionDelta; + private int lifeOffset, lifeOffsetDiff; + private int life, lifeDiff; private int spawnWidth, spawnWidthDiff; private int spawnHeight, spawnHeightDiff; public float duration = 1, durationTimer; @@ -72,37 +71,7 @@ public class ParticleEmitter { private boolean additive = true; public ParticleEmitter () { - this((Texture)null); - } - - public ParticleEmitter (Texture texture) { - this.texture = texture; - initialize(); - - durationValue.setLow(3, 3); - - emissionValue.setHigh(10, 10); - - lifeValue.setHigh(1, 1); - - scaleValue.setHigh(32, 32); - - rotationValue.setLow(1, 360); - rotationValue.setHigh(180, 180); - rotationValue.setTimeline(new float[] {0, 1}); - rotationValue.setScaling(new float[] {0, 1}); - rotationValue.setRelative(true); - - angleValue.setHigh(1, 360); - angleValue.setActive(true); - - velocityValue.setHigh(80, 80); - velocityValue.setActive(true); - - transparencyValue.setHigh(1, 1); - transparencyValue.setTimeline(new float[] {0, 0.2f, 0.8f, 1}); - transparencyValue.setScaling(new float[] {0, 1, 1, 0}); } public ParticleEmitter (BufferedReader reader) throws IOException { @@ -182,6 +151,7 @@ public class ParticleEmitter { public void draw (SpriteBatch spriteBatch, float delta) { delta = Math.min(delta, 0.250f); + int deltaMillis = (int)(delta * 1000); if (additive) spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE); @@ -191,7 +161,7 @@ public class ParticleEmitter { while (true) { index = active.nextSetBit(index); if (index == -1) break; - if (updateParticle(index, delta)) + if (updateParticle(index, delta, deltaMillis)) particles[index].draw(spriteBatch); else { active.clear(index); @@ -204,7 +174,7 @@ public class ParticleEmitter { if (additive) spriteBatch.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); if (delayTimer < delay) { - delayTimer += delta; + delayTimer += deltaMillis; return; } @@ -214,16 +184,16 @@ public class ParticleEmitter { } if (durationTimer < duration) - durationTimer += delta; + durationTimer += deltaMillis; else { if (!continuous) return; restart(); } - emissionDelta += delta; + emissionDelta += deltaMillis; float emissionTime = emission + emissionDiff * emissionValue.getScale(durationTimer / (float)duration); if (emissionTime > 0) { - emissionTime = 1 / emissionTime; + emissionTime = 1000 / emissionTime; if (emissionDelta >= emissionTime) { int emitCount = (int)(emissionDelta / emissionTime); emitCount = Math.min(emitCount, maxParticleCount - activeCount); @@ -247,16 +217,16 @@ public class ParticleEmitter { durationTimer -= duration; duration = durationValue.newLowValue(); - emission = emissionValue.newLowValue(); - emissionDiff = emissionValue.newHighValue(); + emission = (int)emissionValue.newLowValue(); + emissionDiff = (int)emissionValue.newHighValue(); if (!emissionValue.isRelative()) emissionDiff -= emission; - life = lifeValue.newLowValue(); - lifeDiff = lifeValue.newHighValue(); + life = (int)lifeValue.newLowValue(); + lifeDiff = (int)lifeValue.newHighValue(); if (!lifeValue.isRelative()) lifeDiff -= life; - lifeOffset = lifeOffsetValue.active ? lifeOffsetValue.newLowValue() : 0; - lifeOffsetDiff = lifeOffsetValue.newHighValue(); + lifeOffset = lifeOffsetValue.active ? (int)lifeOffsetValue.newLowValue() : 0; + lifeOffsetDiff = (int)lifeOffsetValue.newHighValue(); if (!lifeOffsetValue.isRelative()) lifeOffsetDiff -= lifeOffset; spawnWidth = (int)spawnWidthValue.newLowValue(); @@ -277,7 +247,7 @@ public class ParticleEmitter { if (tintValue.timeline.length > 1) updateFlags |= UPDATE_TINT; } - public void activateParticle (int index) { + private void activateParticle (int index) { Particle particle = particles[index]; if (particle == null) { particles[index] = particle = new Particle(texture); @@ -288,7 +258,7 @@ public class ParticleEmitter { int updateFlags = this.updateFlags; float offsetTime = lifeOffset + lifeOffsetDiff * lifeOffsetValue.getScale(percent); - particle.life = particle.currentLife = life + lifeDiff * lifeValue.getScale(percent); + particle.life = particle.currentLife = life + (int)(lifeDiff * lifeValue.getScale(percent)); if (velocityValue.active) { particle.velocity = velocityValue.newLowValue(); @@ -299,7 +269,12 @@ public class ParticleEmitter { particle.angle = angleValue.newLowValue(); particle.angleDiff = angleValue.newHighValue(); if (!angleValue.isRelative()) particle.angleDiff -= particle.angle; - if ((updateFlags & UPDATE_ANGLE) == 0) particle.angle = particle.angle + particle.angleDiff * angleValue.getScale(0); + if ((updateFlags & UPDATE_ANGLE) == 0) { + float angle = particle.angle + particle.angleDiff * angleValue.getScale(0); + particle.angle = angle; + particle.angleCos = MathUtils.cosDeg(angle); + particle.angleSin = MathUtils.sinDeg(angle); + } particle.scale = scaleValue.newLowValue() / texture.getWidth(); particle.scaleDiff = scaleValue.newHighValue() / texture.getWidth(); @@ -402,36 +377,51 @@ public class ParticleEmitter { particle.setBounds(x - texture.getWidth() / 2, y - texture.getHeight() / 2, texture.getWidth(), texture.getHeight()); } - public boolean updateParticle (int index, float delta) { + private boolean updateParticle (int index, float delta, int deltaMillis) { Particle particle = particles[index]; - float life = particle.currentLife - delta; + int life = particle.currentLife - deltaMillis; if (life <= 0) return false; particle.currentLife = life; - float percent = 1 - particle.currentLife / particle.life; + float percent = 1 - particle.currentLife / (float)particle.life; int updateFlags = this.updateFlags; if ((updateFlags & UPDATE_SCALE) != 0) particle.setScale(particle.scale + particle.scaleDiff * scaleValue.getScale(percent)); - float angle = particle.angle; - if ((updateFlags & UPDATE_ANGLE) != 0) angle += particle.angleDiff * angleValue.getScale(percent); - - if ((updateFlags & UPDATE_ROTATION) != 0) { - float rotation = particle.rotation + particle.rotationDiff * rotationValue.getScale(percent); - if (aligned) rotation += angle; - if (rotation != 0) particle.setRotation(rotation); - } - if ((updateFlags & UPDATE_VELOCITY) != 0) { float velocity = (particle.velocity + particle.velocityDiff * velocityValue.getScale(percent)) * delta; - float velocityX = velocity * MathUtils.cosDeg(angle); - float velocityY = velocity * MathUtils.sinDeg(angle); + + float velocityX, velocityY; + if ((updateFlags & UPDATE_ANGLE) != 0) { + float angle = particle.angle += particle.angleDiff * angleValue.getScale(percent); + velocityX = velocity * MathUtils.cosDeg(angle); + velocityY = velocity * MathUtils.sinDeg(angle); + if ((updateFlags & UPDATE_ROTATION) != 0) { + float rotation = particle.rotation + particle.rotationDiff * rotationValue.getScale(percent); + if (aligned) rotation += angle; + particle.setRotation(rotation); + } + } else { + velocityX = velocity * particle.angleCos; + velocityY = velocity * particle.angleSin; + if ((updateFlags & UPDATE_ROTATION) != 0) { + float rotation = particle.rotation + particle.rotationDiff * rotationValue.getScale(percent); + if (aligned) rotation += particle.angle; + particle.setRotation(rotation); + } + } + if ((updateFlags & UPDATE_WIND) != 0) velocityX += (particle.wind + particle.windDiff * windValue.getScale(percent)) * delta; + if ((updateFlags & UPDATE_GRAVITY) != 0) velocityY += (particle.gravity + particle.gravityDiff * gravityValue.getScale(percent)) * delta; + particle.translate(velocityX, velocityY); + } else { + if ((updateFlags & UPDATE_ROTATION) != 0) + particle.setRotation(particle.rotation + particle.rotationDiff * rotationValue.getScale(percent)); } float[] color; @@ -702,52 +692,57 @@ public class ParticleEmitter { } public void load (BufferedReader reader) throws IOException { - name = readString(reader, "name"); - reader.readLine(); - delayValue.load(reader); - reader.readLine(); - durationValue.load(reader); - reader.readLine(); - setMinParticleCount(readInt(reader, "minParticleCount")); - setMaxParticleCount(readInt(reader, "maxParticleCount")); - reader.readLine(); - emissionValue.load(reader); - reader.readLine(); - lifeValue.load(reader); - reader.readLine(); - lifeOffsetValue.load(reader); - reader.readLine(); - xOffsetValue.load(reader); - reader.readLine(); - yOffsetValue.load(reader); - reader.readLine(); - spawnShapeValue.load(reader); - reader.readLine(); - spawnWidthValue.load(reader); - reader.readLine(); - spawnHeightValue.load(reader); - reader.readLine(); - scaleValue.load(reader); - reader.readLine(); - velocityValue.load(reader); - reader.readLine(); - angleValue.load(reader); - reader.readLine(); - rotationValue.load(reader); - reader.readLine(); - windValue.load(reader); - reader.readLine(); - gravityValue.load(reader); - reader.readLine(); - tintValue.load(reader); - reader.readLine(); - transparencyValue.load(reader); - reader.readLine(); - attached = readBoolean(reader, "attached"); - continuous = readBoolean(reader, "continuous"); - aligned = readBoolean(reader, "aligned"); - additive = readBoolean(reader, "additive"); - behind = readBoolean(reader, "behind"); + try { + name = readString(reader, "name"); + reader.readLine(); + delayValue.load(reader); + reader.readLine(); + durationValue.load(reader); + reader.readLine(); + setMinParticleCount(readInt(reader, "minParticleCount")); + setMaxParticleCount(readInt(reader, "maxParticleCount")); + reader.readLine(); + emissionValue.load(reader); + reader.readLine(); + lifeValue.load(reader); + reader.readLine(); + lifeOffsetValue.load(reader); + reader.readLine(); + xOffsetValue.load(reader); + reader.readLine(); + yOffsetValue.load(reader); + reader.readLine(); + spawnShapeValue.load(reader); + reader.readLine(); + spawnWidthValue.load(reader); + reader.readLine(); + spawnHeightValue.load(reader); + reader.readLine(); + scaleValue.load(reader); + reader.readLine(); + velocityValue.load(reader); + reader.readLine(); + angleValue.load(reader); + reader.readLine(); + rotationValue.load(reader); + reader.readLine(); + windValue.load(reader); + reader.readLine(); + gravityValue.load(reader); + reader.readLine(); + tintValue.load(reader); + reader.readLine(); + transparencyValue.load(reader); + reader.readLine(); + attached = readBoolean(reader, "attached"); + continuous = readBoolean(reader, "continuous"); + aligned = readBoolean(reader, "aligned"); + additive = readBoolean(reader, "additive"); + behind = readBoolean(reader, "behind"); + } catch (RuntimeException ex) { + if (name == null) throw ex; + throw new RuntimeException("Error parsing emitter: " + name, ex); + } } static String readString (BufferedReader reader, String name) throws IOException { @@ -769,11 +764,12 @@ public class ParticleEmitter { } static class Particle extends Sprite { - float life, currentLife; + int life, currentLife; float scale, scaleDiff; float rotation, rotationDiff; float velocity, velocityDiff; float angle, angleDiff; + float angleCos, angleSin; float transparency, transparencyDiff; float wind, windDiff; float gravity, gravityDiff; -- 2.11.0