OSDN Git Service

[changed] BitmapFont and a few other classes to use nearest rather than linear when...
authornathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Mon, 10 Jan 2011 02:00:30 +0000 (02:00 +0000)
committernathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Mon, 10 Jan 2011 02:00:30 +0000 (02:00 +0000)
[added] allowCompletion to ParticleEmitter to allow the emitter to be restarted with continuous respected.

extensions/hiero/src/com/badlogic/gdx/hiero/Hiero.java
extensions/particle-editor/src/com/badlogic/gdx/graphics/particles/ParticleEditor.java
extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/GdxTexture.java
gdx/src/com/badlogic/gdx/graphics/g2d/BitmapFont.java
gdx/src/com/badlogic/gdx/graphics/g2d/ParticleEffect.java
gdx/src/com/badlogic/gdx/graphics/g2d/ParticleEmitter.java

index eac43ec..76c5f7e 100644 (file)
@@ -478,6 +478,7 @@ public class Hiero extends JFrame {
                                dialog.setVisible(true);\r
                                String fileName = dialog.getFile();\r
                                if (fileName == null) return;\r
+                               if (!fileName.endsWith(".hiero")) fileName += ".hiero";\r
                                File file = new File(dialog.getDirectory(), fileName);\r
                                try {\r
                                        save(file);\r
index 85d3e31..cd36886 100644 (file)
@@ -318,7 +318,7 @@ public class ParticleEditor extends JFrame {
                                        file = Gdx.files.classpath(imagePath);\r
                                else\r
                                        file = Gdx.files.absolute(imagePath);\r
-                               emitter.setSprite(new Sprite(Gdx.graphics.newTexture(file, TextureFilter.Linear, TextureFilter.Linear,\r
+                               emitter.setSprite(new Sprite(Gdx.graphics.newTexture(file, TextureFilter.Nearest, TextureFilter.Nearest,\r
                                        TextureWrap.ClampToEdge, TextureWrap.ClampToEdge)));\r
                        } catch (GdxRuntimeException ex) {\r
                                ex.printStackTrace();\r
index 17299f9..c21302c 100644 (file)
@@ -42,7 +42,7 @@ class GdxTexture implements Texture, Resource {
 
        public GdxTexture (GdxRenderer renderer, FileHandle textureFile) {
                this.renderer = renderer;
-               texture = Gdx.graphics.newTexture(textureFile, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,
+               texture = Gdx.graphics.newTexture(textureFile, TextureFilter.Nearest, TextureFilter.Nearest, TextureWrap.ClampToEdge,
                        TextureWrap.ClampToEdge);
        }
 
index 4d4e179..f24338e 100644 (file)
@@ -104,7 +104,7 @@ public class BitmapFont {
         * @param flip If true, the glyphs will be flipped for use with a perspective where 0,0 is the upper left corner.\r
         */\r
        public BitmapFont (FileHandle fontFile, FileHandle imageFile, boolean flip) {\r
-               region = new TextureRegion(Gdx.graphics.newTexture(imageFile, TextureFilter.Linear, TextureFilter.Linear,\r
+               region = new TextureRegion(Gdx.graphics.newTexture(imageFile, TextureFilter.Nearest, TextureFilter.Nearest,\r
                        TextureWrap.ClampToEdge, TextureWrap.ClampToEdge));\r
                init(fontFile, region, flip);\r
        }\r
@@ -134,7 +134,7 @@ public class BitmapFont {
                                if (!page[2].startsWith("file=")) throw new GdxRuntimeException("Invalid font file: " + fontFile);\r
                                String imgFilename = page[2].substring(6, page[2].length() - 1);\r
                                FileHandle imageFile = fontFile.parent().child(imgFilename);\r
-                               region = new TextureRegion(Gdx.graphics.newTexture(imageFile, TextureFilter.Linear, TextureFilter.Linear,\r
+                               region = new TextureRegion(Gdx.graphics.newTexture(imageFile, TextureFilter.Nearest, TextureFilter.Nearest,\r
                                        TextureWrap.ClampToEdge, TextureWrap.ClampToEdge));\r
                        }\r
 \r
@@ -321,7 +321,7 @@ public class BitmapFont {
                                x += g.xadvance * scaleX;\r
                        }\r
                }\r
-               spriteBatch.setColor(batchColor);               \r
+               spriteBatch.setColor(batchColor);\r
                textBounds.width = (int)(x - startX);\r
                textBounds.height = (int)capHeight;\r
                return textBounds;\r
@@ -369,7 +369,7 @@ public class BitmapFont {
                        numLines++;\r
                }\r
                spriteBatch.setColor(batchColor);\r
-               \r
+\r
                textBounds.width = maxWidth;\r
                textBounds.height = (int)(capHeight + (numLines - 1) * lineHeight);\r
                return textBounds;\r
@@ -435,7 +435,7 @@ public class BitmapFont {
                        y += down;\r
                        numLines++;\r
                }\r
-               spriteBatch.setColor(batchColor);               \r
+               spriteBatch.setColor(batchColor);\r
                textBounds.width = maxWidth;\r
                textBounds.height = (int)(capHeight + (numLines - 1) * lineHeight);\r
                return textBounds;\r
index d81bc50..ab6dd2e 100644 (file)
@@ -33,8 +33,8 @@ public class ParticleEffect {
        private ArrayList<ParticleEmitter> emitters = new ArrayList();\r
 \r
        public void start () {\r
-               for (ParticleEmitter emitter : emitters)\r
-                       emitter.start();\r
+               for (int i = 0, n = emitters.size(); i < n; i++)\r
+                       emitters.get(i).start();\r
        }\r
 \r
        public void draw (SpriteBatch spriteBatch, float delta) {\r
@@ -43,11 +43,8 @@ public class ParticleEffect {
        }\r
 \r
        public void allowCompletion () {\r
-               for (int i = 0, n = emitters.size(); i < n; i++) {\r
-                       ParticleEmitter emitter = emitters.get(i);\r
-                       emitter.setContinuous(false);\r
-                       emitter.durationTimer = emitter.duration;\r
-               }\r
+               for (int i = 0, n = emitters.size(); i < n; i++)\r
+                       emitters.get(i).allowCompletion();\r
        }\r
 \r
        public boolean isComplete () {\r
@@ -158,7 +155,7 @@ public class ParticleEffect {
        }\r
 \r
        protected Texture loadTexture (FileHandle file) {\r
-               return Gdx.graphics.newTexture(file, TextureFilter.Linear, TextureFilter.Linear, TextureWrap.ClampToEdge,\r
+               return Gdx.graphics.newTexture(file, TextureFilter.Nearest, TextureFilter.Nearest, TextureWrap.ClampToEdge,\r
                        TextureWrap.ClampToEdge);\r
        }\r
 }\r
index f1eb16f..d774a88 100644 (file)
@@ -64,6 +64,7 @@ public class ParticleEmitter {
        private boolean firstUpdate;\r
        private boolean flipX, flipY;\r
        private int updateFlags;\r
+       private boolean allowCompletion;\r
 \r
        private int emission, emissionDiff, emissionDelta;\r
        private int lifeOffset, lifeOffsetDiff;\r
@@ -194,7 +195,7 @@ public class ParticleEmitter {
                if (durationTimer < duration)\r
                        durationTimer += deltaMillis;\r
                else {\r
-                       if (!continuous) return;\r
+                       if (!continuous || allowCompletion) return;\r
                        restart();\r
                }\r
 \r
@@ -215,6 +216,7 @@ public class ParticleEmitter {
 \r
        public void start () {\r
                firstUpdate = true;\r
+               allowCompletion = false;\r
                restart();\r
        }\r
 \r
@@ -487,6 +489,15 @@ public class ParticleEmitter {
                }\r
        }\r
 \r
+       /**\r
+        * Ignores the {@link #setContinuous(boolean) continuous} setting until the emitter is started again. This allows the emitter\r
+        * to stop smoothly.\r
+        */\r
+       public void allowCompletion () {\r
+               allowCompletion = true;\r
+               durationTimer = duration;\r
+       }\r
+\r
        public Sprite getSprite () {\r
                return sprite;\r
        }\r