HomeForumSearchRegister
Pages: [1]
Topic: Loading Screen  (Read 777 times)
0 Members and 1 Sneaky Snooper are viewing this topic.
ngoaho
  Male
**
Rep: +1/-2
Level 16 (87%)
Real-time RPG is great
View Profile WWW
« on: January 20, 2010, 10:15:33 PM »
IP Logged

a script that give a loading screen when transition start
give credit if use
Code:
#==============================================================================
# Now Loading
# a script that give a loading screen when transition start
# writen by: ngoa ho
# http://www.ngoaho.net- ngoaho91@yahoo.com.vn
#==============================================================================
module NowLoading
  module_function
  def start(text="§ang t¶i...")
    @start = Thread.new do
      bitmap = Bitmap.new(640,50)
      bitmap.font.size = 15
      bitmap.fill_rect(0,0,640,50,$colorlib.black(150))
      bitmap.draw_text(0,0,640,50,text,1)
      @loading_spr = Sprite.new
      @loading_spr.bitmap = bitmap
      @loading_spr.y = 205
      @loading_spr.z = 9999
      loop do
        sleep(0.001)
        Graphics.update
      end
    end
  end
  def stop
    @start.exit unless @start.nil?
    @loading_spr.dispose unless @loading_spr.nil?
  end
end
# use:
# def initialize(*args)
#   NowLoading::start([intro text])
# end
# def load_ok
#   NowLoading::stop
# end
« Last Edit: January 20, 2010, 10:17:56 PM by ngoaho »

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
ngocthang26
 
*
Rep: +0/-1
Level 15 (17%)
View Profile
« Reply #1 on: January 21, 2010, 10:14:04 AM »
IP Logged

I do not think will meet ngoaho
ngoaho
  Male
**
Rep: +1/-2
Level 16 (87%)
Real-time RPG is great
View Profile WWW
« Reply #2 on: January 22, 2010, 12:36:11 PM »
IP Logged

ah, hi ngocthang26, nice to meet you at here

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
ngocthang26
 
*
Rep: +0/-1
Level 15 (17%)
View Profile
« Reply #3 on: January 25, 2010, 07:13:31 PM »
IP Logged

me too
Zylos
  Male
*
The seed of light that man has sown,
Rep: +227/-127
Level 63 (86%)
Proof of age to show we have grown.
View Profile
« Reply #4 on: January 25, 2010, 08:35:59 PM »
IP Logged

What kind of loading screen is this? Can we get a screenshot?

grafikal
  Male
*****
Resource Artist
Rep: +153/-97
Level 65 (02%)
Dog Hat
View Profile
« Reply #5 on: January 25, 2010, 08:38:55 PM »
IP Logged

Zylos, first you have to say something in gibberish and then translate into their language Smiley


ngoaho
  Male
**
Rep: +1/-2
Level 16 (87%)
Real-time RPG is great
View Profile WWW
« Reply #6 on: January 26, 2010, 10:55:22 PM »
IP Logged

in script

loading, you can change loading text each time you load.

load ok, new scene

- play audition with me.
- oh, i'm playing jx now.
- leave it, play audition with me.
- ok ok, audition...i'm gonna download now, oh my god, over 2Gb.
- what?
- my hdd is not enough.
- so, why jx is ok.
- oh, jx is ~1Gb, it's enough.
- hmm, you don't want to play with me?
- oh, i want, but it not possible.
- huh, you think your computer is more important than me....

so she angry, not talk with me within 1 week.
stripe103
  Male
***
Rep: +3/-5
Level 39 (53%)
It's human to misdo
View Profile
« Reply #7 on: January 30, 2010, 02:20:23 PM »
IP Logged

I've tried several times. I put it in the Scene_Title so it would show that it loads when it starts. The only problem is that when it comes to the line: NowLoading::start("Loading...") the game just exits. Please help me. I would really like this script.

stripe103
  Male
***
Rep: +3/-5
Level 39 (53%)
It's human to misdo
View Profile
« Reply #8 on: February 27, 2010, 01:36:52 PM »
IP Logged

BIG BUMP

Zeriab
 
*
☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ The nice kind of alien~
Rep: +152/-9
Level 65 (28%)
Martian - Occasionally kind
View Profile WWW
« Reply #9 on: February 28, 2010, 08:37:02 AM »
IP Logged

Hi ngoaho ^_^

It's nice seeing an actual loading script and not one of the fake loading screen which does nothing for a while.
Am I correct in assuming that $colorlib.black(150) is Color.new(0,0,0,150)?
Either way I suggest that you replace $colorlib.black(150) with the corresponding color since $colorlib is nil in the default scripts.

I suggest that you send a signal to the thread which then takes care of shutting down properly.
Here is a modification of the script showing you what I mean:
Code:
#==============================================================================
# Now Loading
# a script that give a loading screen when transition start
# writen by: ngoa ho
# http://www.ngoaho.net- ngoaho91@yahoo.com.vn
#==============================================================================
module NowLoading
  module_function
  def start(text="§ang t¶i...")
    @start = Thread.new do
      # Create sprite
      bitmap = Bitmap.new(640,50)
      bitmap.font.size = 15
      bitmap.fill_rect(0,0,640,50,Color.new(0,0,0,150))
      bitmap.draw_text(0,0,640,50,text,1)
      @loading_spr = Sprite.new
      @loading_spr.bitmap = bitmap
      @loading_spr.y = 205
      @loading_spr.z = 9999
      # Wait
      loop do
        Graphics.update
        sleep(1)
        # Stop waiting if the loading is done
        break if Thread.current[:done] == true
      end
      # Clean up
      @loading_spr.dispose
    end
  end
  def stop
    if !@start.nil? && @start.alive?
      # Tell the thread that it should stop
      @start[:done] = true
      # Wakes the thread so we don't have to wait for the sleep
      @start.wakeup
      # Wait for the thread to finish
      @start.join
    end
  end
end

Notice that I have changed sleep(0.001) to sleep(1). Since it has no animation there is no reason to call Graphics.update so often.
All threads pause when Graphics.update is called. So the fewer calls the better.

I suggest making it animated:
1. Loading
2. Loading.
3. Loading..
4. Loading...
1. Loading

It will give people a feeling of something happening.
Perhaps a sleep(0.4) will feel better for the animation. Maybe more, maybe less.


You should note that creating sprites in the main thread while the loading thread is running is dangerous due to potential race conditions. I.e. Sprite creation is not thread-safe.

@stripe103:
Do you really need this script?
I tried using the script for loading the database in the default scripts. The loading bar flashed and was gone.
Remember that this is an actual loading script. It involves multithreading and thus should only be used if you have a real need for it.
If you just want to fake it I suggest using one of the many of them out there.

*hugs*
 - Zeriab

garygill <3
stripe103
  Male
***
Rep: +3/-5
Level 39 (53%)
It's human to misdo
View Profile
« Reply #10 on: February 28, 2010, 01:41:57 PM »
IP Logged

No I don't want to fake anything, but it is good to have because me and a couple of friends are going to make a quite big game(hopefully)

Jirbytaylor
  Male
**
Rep: +0/-0
Level 57 (51%)
that avatar is so freaking old
View Profile WWW
« Reply #11 on: March 13, 2010, 09:16:30 PM »
IP Logged

Is this really a loading screen though? All I can make of it is a script that turns on or off a string a transparent rectangle.
You have to control when the text should appear and disappear. While I have figured out how to show what is being loaded (by adding multiple calls to the database loading in Scene_Title), shouldn't a real loading screen detect if data is being loaded and automatically activate itself?

sdfsdf
grafikal
  Male
*****
Resource Artist
Rep: +153/-97
Level 65 (02%)
Dog Hat
View Profile
« Reply #12 on: March 13, 2010, 10:02:55 PM »
IP Logged

it doesn't load anything, it's aesthetic which isn't really aesthetic because no one likes loading screens unless you need them.


Zeriab
 
*
☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ ☺ The nice kind of alien~
Rep: +152/-9
Level 65 (28%)
Martian - Occasionally kind
View Profile WWW
« Reply #13 on: March 14, 2010, 09:00:44 AM »
IP Logged

You guys obviously don't understand the concept of threads.
Even so I believed that you didn't need to know how to use threads to use this loading screen.
You just need to know that you have to be careful about creating sprites and windows in the main thread.
I am surprised though as I thought the post with the big picture explained how to use it very well.
I am disappointed in you guys.

@stripe: I dunno why it simple exits the game. It sound very strange. Unless you don't do anything afterwards.

*hugs*

garygill <3
Pages: [1]
Jump to:  

hi