目前我正在使用以下计算来独立计算字体比例分辨率:
fontScale = ( Gdx.graphics.getDensity() / BaseDensity ) * (( (float)Gdx.graphics.getWidth() / (float)BaseResolutionWidth ) / (Gdx.graphics.getDensity() / BaseDensity) );
我正在使用以下代码将我的字体相对于彼此定位:
font.draw(batch, glyphLayout, UniX(0.5f) - w * 0.5f, UniY(0.23f + 0.04f * scale) - h * 0.5f);
我完全糊涂了。这些文本在我的8英寸平板电脑上显示在彼此内部,但它们在我的手机上完全正确。
如何正确定位此分辨率?
答案 0 :(得分:0)
由于我严格在纵向模式下使用我的应用程序,因此我使用以下宽高比。这似乎可以完美地跨越我的设备(手机和平板电脑)。
aspectRatio = ( Gdx.graphics.getHeight() / Gdx.graphics.getWidth() );
fontScale = ( ( Gdx.graphics.getDensity() / BaseDensity ) * aspectRatio );