如何在Andengine游戏Activity中使用原生Textview(View)
我想知道是否有任何方法可以在 BaseAndEngine Activity
中使用本机 TextView
或 Android 的任何其他布局。
我的应用程序正在将 Andengine 用于其整个屏幕之一。该屏幕是从 BaseAndEngine 扩展的,我需要在该屏幕内使用一些本机视图,例如文本视图。因为 Andengine 不能很好地处理阿拉伯文本,我需要在游戏屏幕上显示一些阿拉伯文本。
或者如果可能的话如何在 Andengine 中以可更改的文本显示阿拉伯文本。作为可变文本,以相反的顺序从左到右书写阿拉伯语。
I want to know is there any way to use native TextView
or any other layout of android inside BaseAndEngine Activity
.
My application is using Andengine for one of its whole screen. This screen is extended from BaseAndEngine and I need to use some native view like textview inside that screen. Because Andengine does not work fine for Arabic text and I need to show some Arabic text on gaming screen.
OR if possible how to show Arabic text in changeable text in Andengine. As changeable text write Arabic from left to right in reverse order.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
您也可以将 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...它会让你的游戏变得丑陋...
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
当然可以。
检查一下这段代码 - 基本上你覆盖
onSetContentView
,然后你可以设置任何你想要的。(这个方法会转到你的
BaseGameActivity
的子类。)你也可以通过xml来做到这一点,但我认为这个方法更清晰。
Of course you can.
Check this code out - basically you override
onSetContentView
, then you can set whatever you want.(This method goes to your subclass of
BaseGameActivity
.)You could also do it through xml, but I think this method is more clear.