Because the case is relatively simple, so simply use Androidapplication-> Game-> Stage Build the framework
first, the main entrance, no special
Copy Code code as follows:
public class App extends Androidapplication {
@Override
public void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Initialize Demo
Initialize (new Demo (), false);
}
}
second, the game main class
Here we need the resource loader to manage the resources, here for testing, you can add more pictures to the effect of obvious points. Here we also use the stage and use the adaptive resolution.
The key here is to constantly refresh the resource manager in the rendering method, and get the current load progress and pass it to the stage processing.
Copy Code code as follows:
public class Demo extends Game {
Explorer
Private Assetmanager Assetmanager = null;
Stage Sub Class
Private Scene Scene = null;
@Override
public void Create () {
Build Explorer
Assetmanager = new Assetmanager ();
Load test picture
for (int i = 1; I <= 6; i++)
Assetmanager.load ("map" + i + ". png", texture.class);
Generate stage, 480x800 as base resolution, default extension
Scene = new Scene (480, 800);
}
@Override
public void render () {
Gdx.gl.glClear (Gl10.gl_color_buffer_bit);
Refreshing explorer
Assetmanager.update ();
Gets the resource load percentage, 1 represents 100%
Float progress = assetmanager.getprogress ();
Scene.draw (progress);
}
}
third, stage class
There is no special place, just show the progress parameters obtained.
Copy Code code as follows:
public class Scene extends Stage {
Private Bitmapfont font;
Public Scene (float width, float height) {
Super (width, height, true);
Font = new Bitmapfont (Gdx.files.internal ("F.fnt"), false);
Font.setscale (0.6f);
}
public void Draw (float t) {
Super.draw ();
Batch.begin ();
if (T < 1.0f) {
Font.draw (Batch, "Loading" + (int) (T *) + "%", 20f,
HEIGHT/2F);
} else {
Font.draw (Batch, "loaded successfully", 20f, height/2f);
}
Batch.end ();
}
}
Four, the procedure screenshot
SOURCE download