11-14-2005, 01:00 PM
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Here's a simple script. Some of the features are "taken" from "Alestian Story", the rest are my creation.
Maybe this is my last script of this year. (I'll rest for a while)
How to use?
You need paste this above the Main class:
Code:
#-----------------------------------------------------------------
class Window_Base < Window
#-----------------------------------------------------------------
alias iniciar initialize
def initialize(x,y,width,height)
iniciar(x,y,width,height)
Font.default_size = 22
Font.default_name = "Tahoma"
end
#-----------------------------------------------------------------
def shadow_color
return Color.new(0,0,0,192)
end
#-----------------------------------------------------------------
def line_color
return Color.new(0,0,0,255)
end
#-----------------------------------------------------------------
def color(name,opacity=255)
case name
when "red" then return Color.new(255,0,0,opacity)
when "blue" then return Color.new(0,0,255,opacity)
when "green" then return Color.new(0,255,0,opacity)
when "gray" then return Color.new(128,128,128,opacity)
when "black" then return Color.new(0,0,0,opacity)
when "white" then return Color.new(255,255,255,opacity)
when "yellow" then return Color.new(255,255,0,opacity)
else normal_color end
end
#-----------------------------------------------------------------
def draw_text_outline(x,y,wid,hei,str,ali=0)
self.contents.font.color = line_color
self.contents.draw_text(x+1,y,wid,hei,str,ali)
self.contents.draw_text(x-1,y,wid,hei,str,ali)
self.contents.draw_text(x,y+1,wid,hei,str,ali)
self.contents.draw_text(x,y-1,wid,hei,str,ali)
self.contents.font.color = normal_color
self.contents.draw_text(x,y,wid,hei,str,ali)
end
#-----------------------------------------------------------------
def draw_text_shadow(x,y,wid,hei,str,ali=0)
self.contents.font.color = shadow_color
self.contents.draw_text(x+2,y+2,wid,hei,str,ali)
self.contents.font.color = normal_color
self.contents.draw_text(x,y,wid,hei,str,ali)
end
#-----------------------------------------------------------------
def draw_text_outshadow(x,y,wid,hei,str,ali=0)
self.contents.font.color = line_color
self.contents.draw_text(x+1,y,wid,hei,str,ali)
self.contents.draw_text(x-1,y,wid,hei,str,ali)
self.contents.draw_text(x,y+1,wid,hei,str,ali)
self.contents.draw_text(x,y-1,wid,hei,str,ali)
self.contents.font.color = shadow_color
self.contents.draw_text(x+2,y+2,wid,hei,str,ali)
self.contents.font.color = normal_color
self.contents.draw_text(x,y,wid,hei,str,ali)
end
#-----------------------------------------------------------------
def draw_text_color(x,y,wid,hei,str,c,opacity=255,ali=0)
self.contents.font.color = color(c,opacity)
self.contents.draw_text(x,y,wid,hei,str,ali)
end
#-----------------------------------------------------------------
def draw_text_shadowcolor(x,y,wid,hei,str,c,opacity=255,ali=0)
self.contents.font.color = color(c,opacity)
self.contents.draw_text(x,y+2,wid,hei,str,ali)
self.contents.font.color = normal_color
self.contents.draw_text(x,y,wid,hei,str,ali)
end
#-----------------------------------------------------------------
end
#-----------------------------------------------------------------
This a example scene: (you need to call it)
Code:
class Test #change for Scene_Menu, to test using the Menu.
def main
@text = Window_Base.new(16,16,256,224)
@text.contents = Bitmap.new(@text.width-32,@text.height-32)
@text.contents.draw_text(0,0,224,32,"Normal text.")
@text.draw_text_outline(0,32,224,32,"Outlined text.")
@text.draw_text_shadow(0,64,224,32,"Text with shadow.")
@text.draw_text_outshadow(0,96,224,32,"Outlined text with shadow")
@text.draw_text_color(0,128,224,32,"Green text","green")
@text.draw_text_shadowcolor(0,160,224,32,"Text with blue shadow.","blue",192)
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@text.dispose
end
def update
@text.update
end
end