Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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  
  how to monitor loading of ressources  (Read 2247 times)
0 Members and 1 Guest are viewing this topic.
Offline emzic

Senior Devvie

« Posted 2006-05-30 14:57:24 »


in my game i have a lot of ressources (textures, sounds, maps, models, etc...) which all need to be loaded before the main window should show up.

what is the best way to monitor and visualize the loading progress? should i run a separate thread and constantly check for changed variables?
Offline Ask_Hjorth_Larsen

Junior Devvie

Java games rock!

« Reply #1 - Posted 2006-05-30 17:10:04 »

Is there any problem with the 'obvious' solution of simply printing to standard out or updating some text component every time something has happened? For example, you could increment a counter for every resource loaded. It might not portray the time it is going to take very realistically, but when the user has run the application once or twice it'll be easy to see approximately how far it is into the loading process.
Offline emzic

Senior Devvie

« Reply #2 - Posted 2006-05-30 17:34:52 »

i am sorry, i forgot to mention that i want to watch the loading process from another part of the program. preferably in another thread, so i can display a nice progressbar.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sequalit

Junior Devvie

« Reply #3 - Posted 2006-05-30 19:08:02 »

Use a implementation of MediaTracker for your image loading, when MediaTracker notifies that its done loading, then show the game.

here's a forum link for it




Offline Mr_Light

Senior Devvie

Medals: 1


« Reply #4 - Posted 2006-06-01 06:49:52 »

is the media tracker actually tracking madia yet and not just images?

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Kova

Senior Devvie

« Reply #5 - Posted 2006-06-02 14:40:37 »

I haven't tried it yet, but NIO offers loading file data through buffers and such... maybe you should try that? It gives you insieght how much data was loaded, and you know from the start how much data needs to be loaded so you can create fine progress bar.
Offline noblemaster

« JGO Spiffy Duke »

Medals: 35
Projects: 11

Age of Conquest makes your day!

« Reply #6 - Posted 2006-06-03 02:01:50 »

Yes, I think MediaTracker wouldn't work with all files?

How about using URLConnection? With a thread, you can easy load data from the net and store it in a file + track progress. Something similar to:

 // where to store the data
OutputStream out = new FileOutputStream(localFilePath);   

 // where the file is located we want to download
URLConnection urlConnection = new URL(remoteFileURL).openConnection();     
InputStream in = urlConnection.getInputStream();

// globals
totalSize = urlConnection.getContentLength();
currentSize = 0;
byte buffer[1024];
boolean finished = false;

while (!finished) {
    int size =;
    if (size == -1) {
       finished = true;
    else {
      out.write(buffer, 0, size);
      currentSize += size;

It won't compile. There is also some stuff missing. However, that's what I basically use. With the class variables "currentSize"/"totalSize" you can track the download progress from a separate class. I can send you my "FileDownloader" class if you are interested...

Pages: [1]
  ignore  |  Print  

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

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

nelsongames (68 views)
2018-04-24 18:14:32

ivj94 (751 views)
2018-03-24 14:47:39

ivj94 (81 views)
2018-03-24 14:46:31

ivj94 (605 views)
2018-03-24 14:43:53

Solater (97 views)
2018-03-17 05:04:08

nelsongames (178 views)
2018-03-05 17:56:34

Gornova (388 views)
2018-03-02 22:15:33

buddyBro (1048 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

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 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!