2012-03-15 4 views
1

私は期待どおりTiledSpriteが動作しないようです。マニュアルはありません。AndEngineExamplesの例は役に立ちません。 - 手動 - ちょうどテストの目的のために3x3のタイルに分割TiledSpriteが期待通りに動作しない

@Override 
public void onLoadResources() { 
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); 
    mBlockAtlas = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR_PREMULTIPLYALPHA); 
    mBlockTexture = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(mBlockAtlas, getApplicationContext(), "num_plasma.png", 0, 0, 3, 3); 

    getTextureManager().loadTexture(mBlockAtlas); 
} 

これは私がしました512x512のテクスチャをロードします。

は、このコードを検討してください。さて、これを実行:

public Scene onLoadScene() { 
    mScene = new Scene(); 
    mScene.setBackground(new ColorBackground(0.5f, 0.1f, 0.6f)); 

    TiledSprite foo, foo2; 
    foo = new TiledSprite(0, 0, mBlockTexture); 
    foo.setCurrentTileIndex(1); 
    foo2 = new TiledSprite(0, 200, mBlockTexture); 
    foo2.setCurrentTileIndex(5); 
    mScene.attachChild(foo); 
    mScene.attachChild(foo2); 

    return mScene; 
} 

これは(予想通り)、画面上の2つのスプライトを置きますが、それらの両方が同じタイル(5)を示しています!

同じテクスチャを使用しながら異なるタイルを表示するスプライトの束がある場合、どうすればよいでしょうか?私はあなたがdeepCopy(する必要があると思う

Screenshot of error

答えて

2

)テクスチャあなたはそれを助けた

foo2 = new TiledSprite(0, 200, mBlockTexture.deepCopy()); 
+0

おかげで、同様に、スプライトを作成しているとき。 60以上のスプライトにdeepCopy()を使用すると、メモリが大量に消費されるので、TextureRegionFactory.extractFromTexture()を使用することを考えていますが、そのメソッドはTextureを必要とし、テクスチャはTextureRegionです。あなたはこの作品を作るための手がかりを持っていますか? – bos

+1

私はTextureRegionFactoryを使用していませんが、TextureRegionはgetTexture()のゲッターを持つBaseTextureRegionを拡張します – jmroyalty

+0

本当に時間節約になります。ありがとう! – bos

関連する問題