RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Loading Screen

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 82
a script that give a loading screen when transition start
give credit if use
Code: [Select]
#==============================================================================
# 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 21, 2010, 03:17:56 AM by ngoaho »

*
Rep:
Level 82
I do not think will meet ngoaho

**
Rep:
Level 82
ah, hi ngocthang26, nice to meet you at here

*
Rep:
Level 82

********
Furry Philosopher
Rep:
Level 94
Rawr?
2013 Best RPG Maker User (Creativity)Randomizer - GIAW 11Gold - GIAW 11 (Hard)Secret Santa 2013 ParticipantFor frequently finding and reporting spam and spam bots2012 Best RPG Maker User (Programming)2012 Best RPG Maker User (Mapping)Secret Santa 2012 ParticipantGold - GIAW 9Project of the Month winner for September 2008For taking a crack at the RMRK Wiki2011 Best RPG Maker User (Programming)2011 Kindest Member2011 Best Veteran2010 Most Deserving Of A Promotion2010 Best RPG Maker User (Technical)
What kind of loading screen is this? Can we get a screenshot?




********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Zylos, first you have to say something in gibberish and then translate into their language :)

**
Rep:
Level 82
in script

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

load ok, new scene

***
Rep:
Level 84
It's human to misdo
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.

***
Rep:
Level 84
It's human to misdo

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
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: [Select]
#==============================================================================
# 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

***
Rep:
Level 84
It's human to misdo
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)

***
Rep:
Level 89
slate furry thing
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?

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
it doesn't load anything, it's aesthetic which isn't really aesthetic because no one likes loading screens unless you need them.

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
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. ;9

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

*hugs*

***
Rep:
Level 89
slate furry thing
Nope, I don't understand them. XD; I can see there's something different about this code though.

I just assumed though it would start and close itself before the title. *shrug* No matter, this might be useful for my VX project because sometimes it takes up to 15 seconds to load. D:

**
Rep:
Level 82
long time no visit, thank you zeriab, i forget it.
p/s: i'm looking for a rgss editor, anyone have.
« Last Edit: April 02, 2010, 02:17:10 PM by ngoaho »

*
Rep: +0/-0Level 81
hi all
it seems i don't know to use this script  :P
i where do i put it (ex:Scene_Menu-Scene_Title) or do i use a new page of script ? :-\
 :lol:

**
Rep:
Level 82
hi max2000, put it in a new script page.
follow http://rmrk.net/index.php/topic,37177.msg438509.html#msg438509 to insert a loading screen.