Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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 2283 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 :

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
   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: 485
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: 485
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  
 
 

 
xxMrPHDxx (21 views)
2017-11-21 16:21:00

xxMrPHDxx (14 views)
2017-11-21 16:14:31

xxMrPHDxx (16 views)
2017-11-21 16:10:57

Ecumene (114 views)
2017-09-30 02:57:34

theagentd (150 views)
2017-09-26 18:23:31

cybrmynd (258 views)
2017-08-02 12:28:51

cybrmynd (249 views)
2017-08-02 12:19:43

cybrmynd (247 views)
2017-08-02 12:18:09

Sralse (260 views)
2017-07-25 17:13:48

Archive (878 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org 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‑gaming.org
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!