nicolasgramlich/AndEngine — pull request #178 by arturogutierrez (2012-10-03 12:57:14+00:00)
Title: Adding a new TextureLoaded listener to TextureManager

Hi,

I was trying to make a LoadingScreen when I realized that GLES2 branch doesn't load each texture immediately, they are saved to be loaded in next OpenGL tick but the engine still running (and updating) and you don't know when one or all textures were loaded really.

I made a patch to TextureManager to allow a new loading mode which I named **Incremental Mode**.
This mode only load **one texture per tick** and allow to set a listener which call you when one texture was loaded telling how many remaining textures to be loaded:

```java
public interface TextureManagerListener {
public void onTextureLoaded(int texturesRemaining);
}
```

This way you can create a *Static Loading Screen* very easily or an *Animated Loading Screen* because the OpenGL thread is not paused noticeable time per tick and the drawing code is executed as usually.

Of course, that mode is optional and you need to activate it, example:
```Java
// Setting Incremental Mode
getTextureManager().setIncrementalMode(true);
// Setting texture listener
getTextureManager().setTextureManagerListener(new TextureManager.TextureManagerListener() {
@Override
public void onTextureLoaded(int texturesRemaining) {
// Animate something in LoadingScreen
//....

if (texturesRemaining == 0) {
// Do something when all textures queues were loaded (ex.: change scene)
}
}
});
```