I’m currently working on a game which uses a few .PNG files from
a local folder. When I run the game, these images load very slowly:
here is some pseduo-code representing my game
Screen class extends Thread implements runnable
-every Thread.sleep(50) it passes
its graphics objects (I use two for buffering) and itself as
an observer to either the BattleManager or Overworld Manager
depending on it's state
BattleManager
beginNewBattle()
Toolkit t = Toolkit.getDefaultToolkit();
Image background = t.createImage(filepath);
Image player
Image menubuttons
Image w/e
drawBattle(g, gBuff, Canvas observer)
{
draws Images to gBuff, then draws gBuff to g
}
during the game, beginNewBattle is called within the BattleManager as soon as
a fight is about to break out. But it usually takes a long time (sometimes 10 seconds or so)
to finally display the background (a 1000x800 pixel image).
Is there a way to speed the load process of these Toolkit images, or a way to allow the images to load before
attempting to use them?
Thanks!