Saturn
Saturn

Reputation: 18149

Animate screen while loading textures

My RPG-like game has random battles. When the player enters a random battle, it is necessary for my game to load the textures used within that battle (animated monsters, animations, etc). The textures are quite a lot, and rather big (the battles are very graphical intensive).

Such process consumes significant time. And while it is loading, the whole screen freezes.

The game's map freezes, and the wait time is significant - I personally find it annoying.

I can't afford to preload the textures because, after doing some math, I realized:

I'd prefer to not use a "loading screen" image because it affects my game's design and concept. I want to avoid this approach.

If I could do some kind of animation while loading the textures, it would be great, which leads to my question: is that possible? What kind of animation, you ask? Well, how about... you remember when Final Fantasy used to distort the screen while apparently loading the textures? Something like that. But well, distorting is quite a time-consuming process as well, so maybe just a cool frame-by-frame animation or something.

While writing this, I realized that I could make small pauses between textures (there are multiple textures), and during such pauses, I update the screen to represent the animation's state. However, this is very unlikely to happen, because each texture is 2048x2048, so the animation would be refreshed at a rather laggy (and annoying) rate. I'd prefer to avoid this as well.

Upvotes: 1

Views: 263

Answers (3)

YvesLeBorg
YvesLeBorg

Reputation: 9079

In a similar bind, i chose to

  1. Convert all my animation textures to gzipped PVR. The load time (depending on the device) is improved by a factor of 2 to 4. Any artefacts caused by a conversion to PVR are not noticeable in motion.
  2. I preload the idle animations (almost always on, except during a skill use or when hurt. I do this during the battle scene's fade-in. I control the fade-in myself on a tick rate of 50 ms, and at every frame i fire-up a preload of one of the idles ( there are a maximum of 8 of them, they take 20 or so ms.).
  3. I have an 'engagement' class which computes the entire fight ahead of time. When an animation becomes un-needed, i unload it. Also, during a 'hurt' animation, i prefetch the next skill animation.

loads of fun. Best of luck with your game.

ps. Dont trust the simulator for actual response times. Go to devices rapidly to determine if you really have a performance issue.

pps. About point 1, that caused a significant size reduction for my app.

Upvotes: 1

Robotnik
Robotnik

Reputation: 3800

You could load lower-resolution textures first, and in a background thread (NSOperation I think) kick off the load for the bigger textures, and 'swap' them when done.

As for animation, a lot of games start by loading the small textures when the player is far away, and as they get closer, the higher-res textures will 'fade' in

Upvotes: 0

Coeffect
Coeffect

Reputation: 8866

Since the battles are supposed to be at random, would it be possible to preload the textures for the next battle before that battle happens? Then the battle can start whenever the loading has completed.

  1. Game decides battle should happen soon
  2. Generate random encounter (monsters/background/etc?)
  3. Load textures for the encounter
  4. Start the encounter after the textures have loaded

The battles are still random, it's just that the encounter has been determined a bit before the user is aware a battle is about to happen.

Upvotes: 0

Related Questions