2013-06-01 76 views
2

我正在一個問答遊戲中,有一個問題和答案彈跳 但問題是遊戲工作正常,但是當使用肖像orentation,我的遊戲的問題去從相機界的一半這樣的問題僅僅是可讀文字走出了相機界

如何設置文本以適應相機寬度

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()); 
+0

當您使用AndEnigne時,您只需在應用程序或遊戲中只使用一個方向。 – Siddharth

回答

2

您可以縮放文本

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

或換行符中的「\ n」。

+0

它不工作frnd它只縮放文本bt文本是走出相機寬度 – raj

+0

我試了question.setWidth(CAMERA_WIDTH);但它也不起作用。 – raj

+0

你的andengine版本是什麼?我在GLES2-AE上的示例工作和文本x位置是屏幕的中心 – Alexey

1

@Alexey謝謝我解決了這個問題;當我使用此解決方案時,您的解決方案正常工作

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); 

現在文本位於相機邊界內。