2013-07-01 40 views
0

我正在使用andengine開發遊戲。對於我需要創建紋理的每個精靈和textureRegion如何在引擎中避免更多紋理和紋理區域

Texture bgTexture; 

TextureRegion bgTextureRegion; 

this.bgTexture = new Texture(512, 1024,TextureOptions.BILINEAR_PREMULTIPLYALPHA); 

    this.bgTextureRegion = TextureRegionFactory.createFromAsset(
      this.bgTexture, this, "gfx/bg.png", 0, 0); 

Sprite bgSprite = new Sprite(0, 0, this.bgTextureRegion); 

如果我使用scoreSpritelifeSprite,等我需要重新再爲每個精靈創建一個紋理和textureRegion &。

它增加了遊戲的加載時間。任何解決方案來解決這個問題?

+0

嗨..我有解決方案動態加載紋理和textureRegion http://www.andengine.org/forums/tutorials/dynamically-load-all-textures-紋理區域,t4139.html – JohnRaja

回答

0

實際上,您需要紋理區域爲每個精靈類型,而不是每個精靈實例都需要atlas &。

爲了避免太多的地圖集實例和從磁盤加載時間,你可以使用平鋪PNG爲您的圖形(許多圖像在一個較大的PNG,高達每PNG 1024x1024)。然後你就可以用這裏提到

TextureRegion textureRegion = new TextureRegion(atlas, tiledX, tiledY, TILED_WIDTH, TILED_HEIGHT); 

其他提示和技巧,讓你的紋理區域的精靈類型:

http://www.matim-dev.com/tips-and-tricks---how-to-improve-performance.html

ESP。池,Spritebatch和Spritegroups,剔除和沒有主題背景