我一直在用 AndEngine 做一些 android 编程,并在 Hashtables 上遇到了一些奇怪的问题。
基本上如果我这样做:
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() 的返回值。