1

我现在知道 AndEngine 中所有基本的调整大小的东西,但我还没有偶然发现如何使文本调整大小的好方法。基本上每个人都在做的是所有字体都被声明为位图,比如说 18pt,并希望得到最好的结果。在开发设备上,一切看起来都很清晰,但是当切换到更大的设备上时,它看起来很丑。我是否必须将所有字体加载到更大的 Atlas 中然后缩小?这不可能是一个选择。请帮忙。

4

1 回答 1

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 中使用 Text 和在遇到您的问题之前,我的 2 分钟阅读表明这不再是问题了。)

于 2012-08-12T23:45:21.440 回答