I need to play a short (5-ish second) intro animation, its 133 frames long, but after removing identical frames there are 92 unique frames remaining. This is how I load them :
private void loadIntro() {
if (shouldPlayIntro) {
introTextures = new Texture[133];
for (int i = 0; i < 132; i ++) {
try {
introTextures[i] = new Texture(Gdx.files.internal("assets/intro/Frame ("+i+").jpg"));
} catch (GdxRuntimeException e) { }
}
}
}
The way that works is fairly simple :
- Try to load next frame
- If you cant, the frame has been cut out because it is identical to the previous frame. Just leave that index null, that image was cut out because it is identical to the previous image
(When rendering, if the next frame to be rendered is null then it will render the previous frame)
You might notice also that I am swallowing a Exception, but it is slower to check to see if a file exists and then load it than load it and swallow the exception. Probably bad practice, but I really need all the performance I can get
The problem is that loading these textures takes 1.509 seconds on my laptop (Not too bad, bearable) but a whopping 10.41 seconds on my android tablet (Samsung Galaxy Tab 2)! This makes for a long black screen before playing the intro, and I fear that even with a loading screen that people wont get to play the game because they will think the game is frozen. Also having the loading screen before the intro is not optimal.
How do you guys load an intro and play it? Am I doing it wrong? Should it be taking this long to load?