1
我一直在用AndEngine做一些Android編程,並且遇到了一些使用Hashtables的奇怪的東西。AndEngine的Java Hashtable
基本上,如果我這樣做:
BitmapTextureAtlas m_textureAtlas = new BitmapTextureAtlas(p_baseActivity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
TextureRegion texture1 = BitmapTextureAtlasTextureRegionFactory.createFromAsset(m_textureAtlas, p_baseActivity, "Chrysanthemum.jpg", 0, 0);
m_textureAtlas.load();
Sprite m_sprite1 = new Sprite(0, 0, texture1, p_baseActivity.getEngine().getVertexBufferObjectManager());
this.attachChild(m_sprite1);
一切的話罰款。但如果我這樣做:
BitmapTextureAtlas m_textureAtlas = new BitmapTextureAtlas(p_baseActivity.getTextureManager(), 1024, 1024, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
Hashtable<String, TextureRegion> test = new Hashtable<String, TextureRegion>();
TextureRegion texture1 = test.put("1", BitmapTextureAtlasTextureRegionFactory.createFromAsset(m_textureAtlas, p_baseActivity, "Chrysanthemum.jpg", 0, 0));
m_textureAtlas.load();
Sprite m_sprite1 = new Sprite(0, 0, texture1, p_baseActivity.getEngine().getVertexBufferObjectManager());
this.attachChild(m_sprite1);
它(圖像)閃爍,尺寸都是錯誤的。現在我可以爲這個項目做第一套代碼,但我不確定我是否做錯了什麼,或者我應該避免put()的返回值。
owww我明白了!非常感謝。 – 2013-02-26 09:27:09