From: nathan.sweet Date: Sat, 30 Oct 2010 08:40:56 +0000 (+0000) Subject: [fixed] gdx-twl with font origin changes. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d0387cbd8aaa697331a6abeb28a83e3f8e0549c4;p=mikumikustudio%2Flibgdx-mikumikustudio.git [fixed] gdx-twl with font origin changes. [fixed] gdx-twl bug with screen size changing. --- diff --git a/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/GdxFont.java b/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/GdxFont.java index 6f4f0ded0..f7ccbdfb8 100644 --- a/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/GdxFont.java +++ b/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/GdxFont.java @@ -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 () { diff --git a/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlRenderer.java b/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlRenderer.java index 096aba82b..8d95a5864 100644 --- a/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlRenderer.java +++ b/extensions/twl/gdx-twl/src/com/badlogic/gdx/twl/renderer/TwlRenderer.java @@ -207,8 +207,8 @@ public class TwlRenderer implements Renderer { static public void updateSize (GUI gui) { Renderer renderer = gui.getRenderer(); if (!(renderer instanceof TwlRenderer)) throw new IllegalArgumentException("gui's renderer must be a TwlRenderer."); - ((TwlRenderer)renderer).spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), - Gdx.graphics.getHeight()); + ((TwlRenderer)renderer).spriteBatch.getProjectionMatrix().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), + 0, 0, 1); gui.setSize(); }