I made this real quick. Should only have to modify settings in the Loading module (for basic setup).
[rgss]module Loading
Background = 'Loading'
Time_Between_Load = 4
Load_Range = 1..5
Bar_Rect = Rect.new(320, 240, 128, 12)
Bar_Color1 = Color.new(255, 0, 0)
Bar_Color2 = Color.new(0, 0, 255)
Bar_Color3 = Color.new(128, 128, 128)
Loading_Scenes = [Scene_Map, Scene_Battle]
end
class Loading::Bar < Sprite
include Loading
attr_reader :percent
def initialize
viewport = Viewport.new(Bar_Rect.x, Bar_Rect.y, Bar_Rect.width + 48, Bar_Rect.height)
super(viewport)
self.bitmap = Bitmap.new(Bar_Rect.width + 48, Bar_Rect.height)
self.bitmap.font.size = Bar_Rect.height
@percent = 0
refresh
end
def refresh
self.bitmap.clear
draw_gradient_bar(0, 0, @percent, 100, Bar_Rect.width, Bar_Rect.height)
self.bitmap.draw_text(Bar_Rect.width + 4, 0, 42, self.bitmap.height,
"#{@percent} %")
end
def update
if Graphics.frame_count % Time_Between_Load == 0
@percent = [@percent + Load_Range.random, 100].min
refresh
end
end
def draw_gradient_bar(x, y, cur, max, width = 152, height = 8,
s_color = Bar_Color1, e_color = Bar_Color2, b_color = Bar_Color3)
self.bitmap.fill_rect(x, y, width, height, b_color)
for i in 1...((cur / max.to_f) * (width - 1))
c = Color.color_between(s_color, e_color, (i / width.to_f))
self.bitmap.fill_rect(x + i, y + 1, 1, height - 2, c)
end
end
end
class Range
def random
return self.to_a.random
end
end
class Array
def random
return self[rand(size)]
end
end
class Scene_Loading
def initialize(next_scene = Scene_Map)
@next_scene = next_scene
end
def main
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.picture('Loading')
@bar = Loading::Bar.new
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@sprite.dispose
@bar.dispose
end
def update
@bar.update
if @bar.percent == 100
if Input.trigger?(Input::C)
$scene = @next_scene.new
end
end
end
end
for class_name in Loading::Loading_Scenes
s = "class #{class_name};"
unless Module.const_defined?
SDK)
s += " alias_method :seph_loading_#{class_name.to_s.downcase}_init, :initialize;"
s += " def initialize(*args);"
s += " @previous_scene = $scne.class;"
s += " seph_loading_#{class_name.to_s.downcase}_init(*args);"
s += " end;"
end
s += " alias_method :seph_loading_#{class_name.to_s.downcase}_main, :main;"
s += " def main;"
s += " unless @previous_scene == Scene_Loading;"
s += " $scene = Scene_Loading.new(#{class_name});"
s += " return;"
s += " end;"
s += " seph_loading_#{class_name.to_s.downcase}_main;"
s += " end;"
s += "end;"
eval s
end
[/rgss]