2

我正在andengine中开发一个问答游戏,其中有一个问题和答案正在弹跳,但问题是游戏运行良好,但是何时使用肖像定位,我的游戏问题超出了相机范围,因此一半问题只能阅读

如何设置文本以适应相机宽度

mBitmapFont=FontFactory.createFromAsset(this.getFontManager(),this.getTextureManager(),
200, 222, TextureOptions.BILINEAR,this.getAssets(), "Plok.ttf", 32, true, Color.WHITE);

question = new Text(10, 45, mBitmapFont, getString(R.string.question1), getVertexBufferObjectManager());
4

2 回答 2

2

您可以缩放文本

if (question.getWidth() > CAMERA_WIDTH) {
    question.setScale(1/(question.getWidth()/CAMERA_WIDTH));
}

或文本中的“\n”作为换行符。

于 2013-06-01T07:59:40.183 回答
1

@Alexey Thanks I solved the problem; your solution worked when I use your solution with this

    question = new Text(0, 0, mBitmapFont, getString(R.string.question10),
            getVertexBufferObjectManager());
   question.setScale(1/(question.getWidth()/CAMERA_WIDTH));
  question.setPosition((CAMERA_WIDTH - question.getWidth()) * 0.5f,5);

now text is inside camera boundaries.

于 2013-06-01T11:09:20.340 回答