I have been working with AndEngine for a little while now, and have managed to get most things working, but I am having some difficulty with my latest bug. To make a long story short, I have come to a point where I want to combine some images together on a single BitmapTextureAtlas.
These images cannot all be combined to begin with, as certain ones will not be displayed at all times, and each one also goes through its own individual post processing based on user input. After all of this input is done however, it would make things much easier, as well as increase performance slightly, to combine these images onto one texture and have only a single sprite to display all of them (A half dozen layers or so).
I have been trying to do this by doing something similar to the following :
this.mBitmapTextureAtlas = new BitmapTextureAtlas(512, 1024, TextureOptions.NEAREST_PREMULTIPLYALPHA);
this.mFaceTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(mBitmapTextureAtlas, this, "layer1.png",0 ,0);
this.mFaceTextureRegion2 = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mBitmapTextureAtlas, this, "layer2.png",0 ,0);
This almost works, the problem is that (At least from the way I see it) it is overwriting every pixel, so only the final layer added will show up. Trying to dive my way through AndEngine to figure out what I need to do to get this working is a bit overwhelming as an amateur developer, so I was hoping somebody a bit more experienced than myself could give me a hint or two on where to go to manage this.
Of course I am open to other suggestions for my problem as well, this is the solution I came up with, but I'm sure there are other ways!
You won't be able to do it by writing to the texture again and again (as you have learned already.) The solution is going to take a bit of work, but it completely possible.
First, you can use android OS to composite a group of images together. There is already Stack Overflow question that answers this, in which the user provides code to merge an array of bitmaps.
android: how to merge an array of bitmap together in one bitmap?
Then you will need to make TextureSource in Andengine to create a region from a bitmap instead of a resource or asset.
AndEngine Texture from Drawable
Finally you can then pass that TextureRegion to your Sprite.
(step 3: Profit!)