My sprites (which are boxes themselves, but different colors) are all showing as black boxes the second time my andengine activity is loaded. It's odd because usually this problem is due to the texture atlas not being large enough, but I tried doubling the size of the atlas, and this didn't work. So here's the relevant code, any help would be much appreciated!
So to put it out there, the first time I load my game, everything is fine and perfect, but the second time, the sprites appear black.
I've seen other questions where the sprites appear as black boxes but for me they load fine the first time, which does not happen for other questions, and the answers which were given on the other questions did not work for me (they were, atlas needs to be power of two, and atlas is not big enough)
public void loadGameResources(){
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
gameTextureAtlas = new BuildableBitmapTextureAtlas(activity.getTextureManager(), 512, 512, TextureOptions.BILINEAR);
blackTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "blacktile.png");
greyTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "greytile.png");
redTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "redtile.png");
greenTile = BitmapTextureAtlasTextureRegionFactory.createFromAsset(gameTextureAtlas, activity, "greentile.png");
Log.d(gameTextureAtlas+"","didn'tignore");
loadFont();
try{
Log.d("LOPOLL","arrived");
gameTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 1, 0));
Log.d("boom","arrived");
gameTextureAtlas.load();
Log.d("gotHere","arrived");
}catch(Exception e){
Log.d("WrongPlace","arrived");
}
}
(Resource unload method)
public void unloadGameResources(){
if(gameTextureAtlas !=null){
gameTextureAtlas.unload();
}
gameTextureAtlas = null;
// blackTile = null;
// greyTile = null;
// redTile = null;
// greenTile = null;
}
The reason that I commented the section giving the tiletextures a null value is that doing this for some reason created a nullexception error even though I thought the textureregions would be reassigned textures upon reloading the activity as reloading the activity calls the loadgameresources() method