2012-04-05 67 views
1

我現在知道AndEngine中所有基本調整大小的東西,但我還沒有找到如何使文本可調整大小的好方法。基本上每個人都在做的是所有的字體都被聲明爲位圖,讓我們說18pt,並希望最好。在開發設備上,一切看起來都很尖銳,但是當切換到更大的設備時,它看起來相當難看。我是否必須將所有字體加載到更大的地圖集中,然後調整大小?這不可能是一種選擇。請幫忙。AndEngine GLES2 |製作字體可調整大小?

回答

2

您的問題GLES2特定?我不這麼認爲。

字體大小不應隨屏幕大小而變化,但應與密度一起縮放。也許都是。無論如何。在FluxCards我這樣做:

// determine the density 
WindowManager windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); 
Display display = windowManager.getDefaultDisplay(); 
DisplayMetrics displayMetrics = new DisplayMetrics(); 
display.getMetrics(displayMetrics); 
density = displayMetrics.density; 

// scale desired size 25 by density 
int fontSize = (int) (25 * density); 

Texture fontTexture = new BitmapTextureAtlas(1024, 1024, TextureOptions.BILINEAR_PREMULTIPLYALPHA); 
font = new Font(fontTexture, Typeface.create(Typeface.DEFAULT, Typeface.NORMAL), fontSize, true, Color.WHITE); 
mEngine.getTextureManager().loadTexture(fontTexture); 
mEngine.getFontManager().loadFont(font); 

(我的代碼是比較複雜的,我仍然用它苦苦掙扎1024x1024的是,我可以使用的fontTexture與較大的字體和亞洲文字最大,信件不會被寫入有時,我正在尋找如何使用GLES2中的文本和我的2分鐘閱讀之前,我碰到你的問題表明,這不是一個問題了。)

+0

哦謝謝。有一段時間沒有檢查我的計算器帳戶。我一定會嘗試:)。謝謝 – 2012-10-02 17:27:55