Auteur: Illusion
Ce script mets des barres de chargement au debut du jeu
Creer un nouveau scripts au dessus de main et nommer le "bitmap"
Code:
# A gradient bar... no need to explain =P
# Made By Illusion
class Bitmap
def gradient_fill_rect(x, y, width = nil, height = nil, color = nil)
if x.is_a?(Rect)
color = y
height = x.height
end
origin_aplha = color.alpha
temp_color_alpha = 0
for i in 0...height
temp_color_alpha += origin_aplha / height.to_f
temp_color = Color.new(color.red, color.green, color.blue, temp_color_alpha)
if x.is_a?(Rect)
self.fill_rect(x, temp_color)
else
self.fill_rect(x, y + i, width, height - i, temp_color)
end
end
end
end
Creer un nouveau script au dessus de main et nommez le "Game_System"
Code:
class Game_System
#--------------------------------------------------------------------------
# ● Returns the default windowskin name.
#--------------------------------------------------------------------------
def windowskin_name
if @windowskin_name == nil
begin
return $data_system.windowskin_name
rescue
return '001-Blue01'
end
else
return @windowskin_name
end
end
end
Creer un nouveau script au dessus de main et nommez le "Window_Base"
Code:
# ■ Window_Base
#------------------------------------------------------------------------------
# Some modifications to make some special effects.
# By : Illusion
# Descriptions :
# self.shake = true >> Will shake the window and its contents.
# self.bounce(x or y or both) >> Will "bounce" the window up, donw, left and right.
# self.continuous_transparency = true >> Will make the window fade in and out.
# Before setting one these settings in your scene do this :
# @window_thing.x = desired x
# @window_thing.y = desired y
# @window_thing.update
# @window_thing.effect_attribute = true or false
#==============================================================================
class Window_Base
attr_accessor :shake
attr_accessor :bounce_x
attr_accessor :bounce_y
attr_accessor :continuous_transparency
alias effects_initialize initialize
alias effects_update update
def initialize(x, y, width, height)
@old_x = x
@old_y = y
effects_initialize(x, y, width, height)
self.shake = false
self.bounce_x = false
self.bounce_y = false
self.continuous_transparency = false
end
def update
@old_x = self.x unless move_effects
@old_y = self.y unless move_effects
effects_update
# If the window has a shake status, shake it.
if self.shake
self.x = @old_x + rand(5)
self.y = @old_y - rand(5)
end
# If the window has a bouncing status, move it.
if self.bounce_y
@down = true if self.y < @old_y - 40
@down = false if self.y > @old_y+ 10
self.y += 1 if @down
self.y -= 1 unless @down
end
if self.bounce_x
@left = true if self.x < @old_x - 20
@left = false if self.x > @old_x + 30
self.x += 1 if @left
self.x -= 1 unless @left
end
# If the window has a transparency status, change its transparency it.
if self.continuous_transparency
@opacity_up = true if self.opacity <= 10
@opacity_up = false if self.opacity >= 255
self.opacity += 2 if @opacity_up
self.opacity -= 2 unless @opacity_up
end
end
#-------------------------------------------------------------
# ● Enables bouncing effect
#-------------------------------------------------------------
def bounce
self.bounce_x = self.bounce_y = true
end
#-------------------------------------------------------------
# ● Checks that no window effect is active.
#-------------------------------------------------------------
def move_effects
a = false
a = true if self.bounce_x
a = true if self.bounce_y
a = true if self.shake
return a
end
end
Creer un nouveau script au dessus de main et nommez le "Window_Load_Data"
Code:
#==============================================================================
# ■ Window_Load_Data
#------------------------------------------------------------------------------
# Shows the loading data bar and percentage.
# By : Illusion
#==============================================================================
class Window_Load_Data < Window_Base
attr_accessor :text
attr_accessor :color
#--------------------------------------------------------------------------
# ● Initializes the window.
#--------------------------------------------------------------------------
def initialize
super(190, 206, 250 + 32, 30 + 32 - 15)
self.contents = Bitmap.new(250, 32 - 6)
self.contents.font.name = $defaultfonttype
self.contents.font.size = 16
self.contents.font.color = Color.new(255, 255, 255, 255)
@text = ""
@color = Color.new(0, 0, 0, 255)
self.visible = true
end
#--------------------------------------------------------------------------
# ● Updates the bar and the text.
#--------------------------------------------------------------------------
def set_text_and_bar(percentage)
percentage = percentage.floor.to_i
update
# Clears the contents.
self.contents.clear
self.contents.gradient_fill_rect(0, 0, (percentage / 100.0 * self.contents.width), self.contents.height, @color)
text = @text+percentage.to_s+'%'
self.contents.draw_text(8, -4, text.size * 32, 32, text, 0)
end
end