OSDN Git Service

[fixed] gdx-twl with font origin changes.
authornathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sat, 30 Oct 2010 08:40:56 +0000 (08:40 +0000)
committernathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Sat, 30 Oct 2010 08:40:56 +0000 (08:40 +0000)
[fixed] gdx-twl bug with screen size changing.

extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/GdxFont.java
extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlRenderer.java

index 6f4f0de..f7ccbdf 100644 (file)
@@ -93,16 +93,15 @@ class GdxFont implements Font {
 
        public FontCache cacheText (FontCache cache, CharSequence str, int start, int end) {
                if (cache == null) cache = new GdxFontCache();
-               BitmapFontCache bitmapCache = ((GdxFontCache)cache).bitmapCache;
-               bitmapFont.cacheText(bitmapCache, str, 0, yOffset, com.badlogic.gdx.graphics.Color.WHITE, start, end);
+               GdxFontCache bitmapCache = (GdxFontCache)cache;
+               bitmapCache.setText(str, 0, yOffset, com.badlogic.gdx.graphics.Color.WHITE, start, end);
                return cache;
        }
 
        public FontCache cacheMultiLineText (FontCache cache, CharSequence str, int width, de.matthiasmann.twl.HAlignment align) {
                if (cache == null) cache = new GdxFontCache();
-               BitmapFontCache bitmapCache = ((GdxFontCache)cache).bitmapCache;
-               bitmapFont.cacheMultiLineText(bitmapCache, str, 0, yOffset, com.badlogic.gdx.graphics.Color.WHITE, width,
-                       gdxAlignment[align.ordinal()]);
+               GdxFontCache bitmapCache = (GdxFontCache)cache;
+               bitmapCache.setMultiLineText(str, 0, yOffset, com.badlogic.gdx.graphics.Color.WHITE, width, gdxAlignment[align.ordinal()]);
                return cache;
        }
 
@@ -172,26 +171,17 @@ class GdxFont implements Font {
                }
        }
 
-       private class GdxFontCache implements FontCache {
-               final BitmapFontCache bitmapCache;
-
+       private class GdxFontCache extends BitmapFontCache implements FontCache {
                public GdxFontCache () {
-                       bitmapCache = bitmapFont.newCache();
+                       super(bitmapFont);
                }
 
                public void draw (AnimationState as, int x, int y) {
+                       y += bitmapFont.getCapHeight();
                        GdxFont.FontState fontState = evalFontState(as);
-                       bitmapCache.setColor(renderer.getColor(fontState.color));
-                       bitmapCache.setPosition(x + fontState.offsetX, y + fontState.offsetY);
-                       bitmapCache.draw(renderer.spriteBatch);
-               }
-
-               public int getWidth () {
-                       return bitmapCache.getWidth();
-               }
-
-               public int getHeight () {
-                       return bitmapCache.getHeight();
+                       setColor(renderer.getColor(fontState.color));
+                       setPosition(x + fontState.offsetX, y + fontState.offsetY);
+                       draw(renderer.spriteBatch);
                }
 
                public void destroy () {
index 096aba8..8d95a58 100644 (file)
@@ -207,8 +207,8 @@ public class TwlRenderer implements Renderer {
        static public void updateSize (GUI gui) {\r
                Renderer renderer = gui.getRenderer();\r
                if (!(renderer instanceof TwlRenderer)) throw new IllegalArgumentException("gui's renderer must be a TwlRenderer.");\r
-               ((TwlRenderer)renderer).spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(),\r
-                       Gdx.graphics.getHeight());\r
+               ((TwlRenderer)renderer).spriteBatch.getProjectionMatrix().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),\r
+                       0, 0, 1);\r
                gui.setSize();\r
        }\r
 \r