Sign in to follow this  
Goguigo

Loading?

Recommended Posts

What do you mean with "loading"?

Loading your application resources like images, MIDI files, sprites... ?
Or do you mean the time cellphone spend to make itself on?

Or is it another thing? [wink]

Regards,

John.

Share this post


Link to post
Share on other sites
Hi,

The loading screen shows to the user (with a progress bar or something like that), the time that the device is taking to load the images, load MIDI files, create tables, etc...

So, a way to make that is to call the paint method the times you want to update the progress bar. Something like this:



public static void loading(int perc, Graphics g) {
g.setColor(0,0,0);
g.fillRect(0,0,canvasWidth, canvasHeight);
g.setColor(255,255,255);
g.drawString("loading, " + perc + "%", canvasWidth/2, canvasHeight/2, Graphics.TOP | Graphics.HCenter);
}

public boolean loadRes() {
try {
//Load Character Image
Image imgC1 = Image.createImage("/res/c.png");
loading(10, this.g);

//Create enemy object
enemy = new Enemy(ENEMY_1);
loading(20, this.g);

//...

}
catch (Exception e) {
e.printStackTrace();
}
}






Something like this.
It's a idea. Obviously not the better one, but you can improve it. [wink]

Regards,

John.

Share this post


Link to post
Share on other sites
Thanks man.

The sad news is that it didnt work perfectly.... i'm working with a MG150D LG cellphone, and it seems that it has a single buffer or something like that. The thing is that, i tried to create several loading methods and ways... but i get a whit screen allways on that cellphone. The problem is that the game takes 5 segs on loading, and the user may think "damn, maybe the game got stuck... just like windows" (lol).

:(

Thanks tho

Share this post


Link to post
Share on other sites
Maybe is because your app aren't calling repaint() method.

You can try to call repaint() and serviceRepaints() to force the painting method to draw the loading screen.
Another way to do is running the loading method in another thread.

Regards,

John.

Share this post


Link to post
Share on other sites
Thanks man, that fixed the problem. :D


Just curious... how can i load and run the program in 2 diferent threads?

thanks again

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this