【发布时间】:2013-08-03 00:39:52
【问题描述】:
我在精灵中心绘制字体时遇到了一些问题。精灵沿着屏幕移动。我将正交相机设置为:
w = Gdx.graphics.getWidth();
h = Gdx.graphics.getHeight();
camera = new OrthographicCamera(1, h/w);
和:
Sprite spr = new Sprite(starTx);
spr.setSize(0.3f, 0.3f);
spr.setOrigin(0.15f, 0.15f);
spr.setPosition(0.2f, 0.25f*(i+1));
内部渲染我有代码:
batch.setProjectionMatrix(camera.combined);
batch.begin();
spr.draw(batch);
font.setScale(1, (w/h)*3);
font.draw(batchFont, mDate, valueX, valueY);
batch.end();
我必须在精灵的中心绘制字体。谁能告诉我如何计算 valueX 和 ValueY?
【问题讨论】:
-
我自己找到了答案:x = (spr.getX()+0.5f)*(screen.width())
标签: java fonts libgdx sprite center