深刻な低レベルのデバッグを掘り下げる前に、私はスプライト上にテキストを描画するという概念に問題があるかどうか疑問に思っていました。 は、私はこれが行われているが、どこにもありません気付いAPIの例を通じてトロール。すべてのテキストスプライトは、私はほとんど描かれしようとしている何かを見ることができるPNG画像 にプリレンダリングされているが、唯一の任意のアドバイスは私がのユーザーポスト渡って来た 乾杯Andengine - スプライト上にテキストを描画する
public class Tile extends Sprite {
private static BitmapTextureAtlas mBitmapTextureAtlas;
private static TextureRegion mBoxTextureRegion;
private static BitmapTextureAtlas mFontTexture;
private static Font mFont;
String letter;
private Text mText;
public int score;
public Tile(String letter, int score, float x, float y, float width, float height) {
super(x, y, width, height, mBoxTextureRegion);
this.letter = letter;
this.score = score;
}
public static void loadResources(Context context, Engine mEngine) {
Tile.mFontTexture = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
Tile.mFont = FontFactory.createFromAsset(Tile.mFontTexture, context, "Arial Rounded MT.ttf", 64, true, Color.WHITE);
mEngine.getTextureManager().loadTexture(Tile.mFontTexture);
mEngine.getFontManager().loadFont(Tile.mFont);
Tile.mBitmapTextureAtlas = new BitmapTextureAtlas(128, 128, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
Tile.mBoxTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(Tile.mBitmapTextureAtlas, context, "rect3761.png", 0, 0);
mEngine.getTextureManager().loadTexture(Tile.mBitmapTextureAtlas);
}
public void draw(GraphicScene scene) {
if (letter != null) {
this.mText = new Text(50, 50, Tile.mFont, letter, HorizontalAlign.CENTER);
// this.mText.setBlendFunction(GL10.GL_SRC_ALPHA,
// GL10.GL_ONE_MINUS_SRC_ALPHA);
// this.mText.setAlpha(0.5f);
this.attachChild(this.mText);
scene.attachChild(this);
}
}
}
ご回答いただきありがとうございます。それは良い答えです。私は、実際には最終的に私自身のスプライトボタンを作ってしまうので、この質問を忘れませんでした。 しかし、あなたは正しいですので、私は答えとしてこれをマーキングしています。私の問題は、Windowsでフォントとして使用できる.TTFファイルは、andEngine Textクラスで動作すると仮定していました。しかし、それはかなり台無しだった。私は別のフォントを使用して終了し、すべてが期待どおりに働いた。歓声 – Justin
@Justinあなたはテキストをスプライトに従うために使ったクラスとメソッドを投稿できますか? – rasen58