かなり手こずったのでメモ
ストレージのファイルを利用してAndEngineのテクスチャとする方法
[code]
Sprite base = getBaseActivity().getResourceUtil()
.getSpriteFromFile(getBaseActivity().getFilesDir() + "/background.png");
attachChild(base);
public Sprite getSpriteFromFile(String fileName) {
File imageFile = new File(fileName);
FileInputStream imageFis = null;
try {
imageFis = new FileInputStream(imageFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Bitmap bm = BitmapFactory.decodeStream(imageFis);
BitmapTextureAtlas bta = new BitmapTextureAtlas(
gameActivity.getTextureManager(),
getTwoPowerSize(bm.getWidth()),
getTwoPowerSize(bm.getHeight()),
TextureOptions.BILINEAR_PREMULTIPLYALPHA);
gameActivity.getEngine().getTextureManager().loadTexture(bta);
FileBitmapTextureAtlasSource fileTextureSource = FileBitmapTextureAtlasSource.create(imageFile);
TiledTextureRegion btr = BitmapTextureAtlasTextureRegionFactory.createTiledFromSource(bta, fileTextureSource, 0, 0, 1, 1);
Sprite s = new Sprite(0, 0, btr,
gameActivity.getVertexBufferObjectManager());
s.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
return s;
}
[/code]