您也可以使用Andengine進行阿拉伯語和波斯語字體的設置。但以不同的方式。要做到這一點,你需要創建一個Sprite併爲其添加一個位圖。在此之前,您在該位圖上繪製文本。
以下代碼是一個繪製波斯/阿拉伯文字並將其附加到精靈的示例。所以我們可以將精靈附加到我們的場景中。 這是一個例子來說明我們如何做到這一點,所以你可以自己調整位圖和文字大小。 如果您的設備支持波斯/阿拉伯人,此代碼將正常工作。如果文字沒有出現在你的場景中,改變它的位置,它就會出現在屏幕外
示例代碼函數將打印波斯/阿拉伯人的「波斯高爾夫球」。
private void persianGolfPrinter(){
BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas(ResourceManager.getInstance().gameActivity.getTextureManager(), 400, 800, TextureOptions.BILINEAR);
ITextureRegion mDecoratedBalloonTextureRegion;
final IBitmapTextureAtlasSource baseTextureSource = new EmptyBitmapTextureAtlasSource(400, 800);
final IBitmapTextureAtlasSource decoratedTextureAtlasSource = new BaseBitmapTextureAtlasSourceDecorator(baseTextureSource) {
@Override
protected void onDecorateBitmap(Canvas pCanvas) throws Exception {
this.mPaint.setColor(Color.BLACK);
this.mPaint.setStyle(Style.FILL);
this.mPaint.setTextSize(32f);
this.mPaint.setTextAlign(Align.CENTER);
pCanvas.drawText("خلیج فارس", 150, 150, this.mPaint);
}
@Override
public BaseBitmapTextureAtlasSourceDecorator deepCopy() {
throw new DeepCopyNotSupportedException();
}
};
mDecoratedBalloonTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromSource(mBitmapTextureAtlas, decoratedTextureAtlasSource, 0, 0);
mBitmapTextureAtlas.load();
Sprite test = new Sprite(0,0,mDecoratedBalloonTextureRegion,ResourceManager.getInstance().engine.getVertexBufferObjectManager());
this.attachChild(test);
}
不要使用Android的TextView ...它使你的遊戲醜陋....
你好,沒有ü解決表示在andengine多變文本阿拉伯語的問題呢?我現在面臨同樣的問題。你能幫我嗎 –