Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Loading Bar

Author
Message
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 10th Jun 2006 08:27
This is kind of a newbie question, but I was trying to get VanB's Loading Bar code found at http://forum.thegamecreators.com/?m=forum_view&t=29284&b=1 to work with some of my media, but it will not.

Here is my code:


I'm probably using the "for" and "next" commands wrong, but when I try to do it, the loading bar advances once (Which I understand it's supposed to,) but then the application quits because the error states, "Object already exists at line 3"

If anyone can clear this up, I'd appreciate it!
Thanks!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 10th Jun 2006 11:18
Erm, yeah, I think you are mis-understanding things.

First:
For obj =1 to 3
Next (or Next obj) - I've never heard of using Next obj+1???

I personally never use Next obj, as you should structure your programs so that you know what For is matched with what Next, but that is just me. i.e.

seems redundant to me and I use:




The For...Next loop automatically increases by 1 each time through the loop, unless you use STEP to change this as in:
For obj = 1 to 10 step 2
Next
which would count up in twos, looping 5 times in total.

Second:
You need to use the value of obj when calling the progress bar function, other wise it won't increase.
Try:
Progress("Loading Objects:",obj*1/3.0)
Then when obj is 1, Progress is called with 1/3, when obj is 2, 2/3 and finally on the last loop, obj=3 and Progress is called with 1 (i.e. full)

Third:
This is where you are getting the error, and shows a little lack of understanding which hopefully I can help yo with. You are looping three times, and each time you are trying to load three objects:
Load object "Alpha.x",1
Load object "Beta.x",2
Load object "Gamma.x",3
Thing is, after the first loop, they all exist already... Object 1 is alpha.x, object 2 is beta.x and object 3 is gamma.x. So when the loop runs again (obj=2) it trys to recreate object 1 and you get an error.

You could either try without a loop:


Or with a loop and use an array:


Hope this all helps!
Lord Lurd
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location:
Posted: 10th Jun 2006 20:27 Edited at: 10th Jun 2006 21:04
Thankyou. The bar works and I better understand the "For" and "Next" commands and how they will loop!

Thanks!
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 10th Jun 2006 20:42
Its ok. Glad to have helped!
Virtual X
18
Years of Service
User Offline
Joined: 27th Feb 2006
Location:
Posted: 11th Jun 2006 13:57
Lord Lurd, if you want to code a progress bar, your better off calculating the total file size for each object then work out the percentage after each object has loaded based on its file size. That's how I do it anyway.
Aaron Miller
18
Years of Service
User Offline
Joined: 25th Feb 2006
Playing: osu!
Posted: 12th Jun 2006 07:57
I agree with Virtual X. However, A loading bar is a loading bar, the user of the program probobly wont tell the differance.

I have the BEST signature ever! I bet you cant guess what it is!

Login to post a reply

Server time is: 2024-11-26 18:19:42
Your offset time is: 2024-11-26 18:19:42