Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LibGDX] Best way to play an animated intro  (Read 2937 times)
0 Members and 1 Guest are viewing this topic.
Offline saucymeatman
« Posted 2014-04-24 19:12:27 »

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 Sad

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?
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 486
Exp: 7 years

« Reply #1 - Posted 2014-04-24 19:36:20 »

Find out what the bottleneck is on the tablet, it's most likely going to be either loading it from file or decompressing the frames. If the CPU is maxed during that black screen, then it's the compression and you could use less compressed files. If it's very low, then it's probably just the IO which can't be helped much I don't think, besides using more (or different, more appropriate) compression.

My guess is that's it's the decoding/decompression.
Offline Gibbo3771

JGO Kernel

Medals: 128
Projects: 5
Exp: 1 year

Currently inactive on forums :(

« Reply #2 - Posted 2014-04-24 19:41:24 »

Also having the loading screen before the intro is not optimal.

May I ask why?

You would rather have a black screen for a short time and then an animation intro, then load your game...?

Why not just load every single thing on a loading screen, then show the intro? After the intro it just fires right to your menu, no more loading.

Just curious.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline saucymeatman
« Reply #3 - Posted 2014-04-24 21:15:12 »

Well the reason is mostly artistic, the intro video doesn't match the look/feel of the game and I wanted the loading screen to play into the central theme. Having a loading screen before the intro would mean that I would have to match the loading screen to the intro video, which I personally think would look worse. But whichever way I end up going, the load time is way to long Sad

Anyway, right now the files arnt compressed, like at all. Is that the issue? They are just loose .jpg's in a folder. How would I go about loading a compressed file format?
Offline BurntPizza

« JGO Bitwise Duke »

Medals: 486
Exp: 7 years

« Reply #4 - Posted 2014-04-24 21:18:14 »

JPEG is a compressed format, but the level of compression can be varied at encode time. Also JPEG might not be the most appropriate format to use.

Still, you can't be sure what the problem is and thus how to deal with it until you figure out what the bottleneck is.
Pages: [1]
  ignore  |  Print  

hadezbladez (294 views)
2018-11-16 13:46:03

hadezbladez (164 views)
2018-11-16 13:41:33

hadezbladez (295 views)
2018-11-16 13:35:35

hadezbladez (75 views)
2018-11-16 13:32:03

EgonOlsen (2156 views)
2018-06-10 19:43:48

EgonOlsen (2183 views)
2018-06-10 19:43:44

EgonOlsen (1370 views)
2018-06-10 19:43:20

DesertCoockie (1987 views)
2018-05-13 18:23:11

nelsongames (1630 views)
2018-04-24 18:15:36

nelsongames (2278 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!