17 May 2009

Adding Window Text Effects

Using the built-in RGSS/2 script, we can add some cool effects for enhancing or beautifying text, if used properly. These include a shadow effect and outlined text. Both of these scripts should work in both RMXP and RMVX, although I think there's an added font feature in RMVX for creating shadow effects without script.)

Shadow Effect

Add the following to Window_Base:
#---------------------------------------------------
# * Draw Shadow
#     x    : draw spot x-coordinate
#     y    : draw spot y-coordinate
#     w    : width
#     h    : height
#     text : text to display
#----------------------------------------------------
def draw_shadow(x, y, w, h, text)
  # Display shadow/shadow color
  self.contents.font.color = Color.new(200, 200, 200, 205)
  self.contents.draw_text(x + 4, y + 4, w, h, text, 1)
  # Display normal color text
  self.contents.font.color = system_color
  self.contents.draw_text(x, y, w, h, text, 1)
end
This will set up the "define procedure" to place it in windows. As an example, in Window_Steps, replacing this line:

self.contents.draw_text(4, 0, 120, 32, "Step Count")

with this line:

draw_shadow(4, 0, 120, 32, "Step Count")

will result in "Step Count" having a whitish-grey shadow.


Outline Effect

This routine will give the text an outline, which might be used for main headings.

Add the following to Window_Base:
#--------------------------------------------------
# * Draw Outline
#     x    : draw spot x-coordinate
#     y    : draw spot y-coordinate
#     w    : width
#     h    : height
#     text : text to display
#---------------------------------------------------
def draw_outline(x, y, w, h, text)
  self.contents.draw_text(x + 1, y * 32 + 1, w, h, text, 1)
  self.contents.draw_text(x - 1, y * 32 + 1, w, h, text, 1)
  self.contents.draw_text(x + 1, y * 32 - 1, w, h, text, 1)
  self.contents.draw_text(x - 1, y * 32 - 1, w, h, text, 1)
  self.contents.font.color = Color.new(250, 250, 250, 255)
  self.contents.draw_text(x, y * 32, w, h, text, 1)
end

Then, as an example, in Window_Steps, replace this line:

self.contents.draw_text(4, 0, 120, 32, "Step Count")

with this line:

draw_outline(4, 0, 120, 32, "Step Count")

In the Status Menu, the "Step Count" will now have an outlined effect.

0 Comments So Far:

Post a Comment

Related Posts with Thumbnails
Template Design "Perfect World" by SkinCorner