Project1

标题: RMXP字体的阴影问题 [打印本页]

作者: 夕仔    时间: 2014-11-1 19:49
标题: RMXP字体的阴影问题
我使用了字体的阴影脚本,如何在draw_text中使用一个参数即可以不显示阴影
@xxx.draw_text(x, y, width, height, text)
比如像这样 @xxx.draw_text(x, y, width, height, text,false)即可不显示阴影,默认显示阴影@RyanBern
{:2_264:} 拜托了


RUBY 代码复制
  1. #======================================================================
  2. # 脚本来自[url]www.66rpg.com[/url],使用请保留此信息
  3. # 作者:SailCat;升级:柳柳;最后升级日期:2006年4月30日
  4. #======================================================================
  5. class Bitmap
  6.   unless $OK
  7.     alias sailcat_draw_text draw_text
  8.     def draw_text(p1, p2, p3 = 0, p4 = 3, p5 = nil, p6 = 0, p7 = 3, p8 = nil)
  9.       case p1
  10.       when Numeric
  11.         x = p1
  12.         y = p2
  13.         width = p3
  14.         height = p4
  15.         text = p5
  16.         align = p6
  17.         shadow_direction = p7
  18.         shadow_color = p8
  19.         if shadow_color.nil?
  20.           shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
  21.         end
  22.       when Rect
  23.         x = p1.x
  24.         y = p1.y
  25.         width = p1.width
  26.         height = p1.height
  27.         text = p2
  28.         align = p3
  29.         shadow_direction = p4
  30.         shadow_color = p5
  31.         if shadow_color.nil?
  32.           shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
  33.         end
  34.       end
  35.       color_temp = self.font.color.clone
  36.       if shadow_direction != 0
  37.         self.font.color = shadow_color
  38.         case shadow_direction
  39.         when 1
  40.           sailcat_draw_text(x-1, y+1, width, height, text, align)
  41.         when 3
  42.           sailcat_draw_text(x+1, y+1, width, height, text, align)
  43.         when 7
  44.           sailcat_draw_text(x-1, y-1, width, height, text, align)
  45.         when 9
  46.           sailcat_draw_text(x+1, y-1, width, height, text, align)
  47.         end
  48.         self.font.color = color_temp
  49.       end
  50.       $OK = true
  51.       sailcat_draw_text(x, y, width, height, text, align)
  52.     end
  53.   end
  54. end

作者: 恐惧剑刃    时间: 2014-11-1 20:37
  1. #======================================================================
  2. # 脚本来自[url]www.66rpg.com[/url],使用请保留此信息
  3. # 作者:SailCat;升级:柳柳;最后升级日期:2006年4月30日
  4. #======================================================================
  5. # 使用 shadow_draw_text 描绘影子字 使用方法同draw_text
  6. class Bitmap
  7.   #unless $OK
  8.   #  alias sailcat_draw_text draw_text
  9.     def shadow_draw_text(p1, p2, p3 = 0, p4 = 3, p5 = nil, p6 = 0, p7 = 3, p8 = nil)
  10.       case p1
  11.       when Numeric
  12.         x = p1
  13.         y = p2
  14.         width = p3
  15.         height = p4
  16.         text = p5
  17.         align = p6
  18.         shadow_direction = p7
  19.         shadow_color = p8
  20.         if shadow_color.nil?
  21.           shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
  22.         end
  23.       when Rect
  24.         x = p1.x
  25.         y = p1.y
  26.         width = p1.width
  27.         height = p1.height
  28.         text = p2
  29.         align = p3
  30.         shadow_direction = p4
  31.         shadow_color = p5
  32.         if shadow_color.nil?
  33.           shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
  34.         end
  35.       end
  36.       color_temp = self.font.color.clone
  37.       if shadow_direction != 0
  38.         self.font.color = shadow_color
  39.         case shadow_direction
  40.         when 1
  41.           draw_text(x-1, y+1, width, height, text, align)
  42.         when 3
  43.           draw_text(x+1, y+1, width, height, text, align)
  44.         when 7
  45.           draw_text(x-1, y-1, width, height, text, align)
  46.         when 9
  47.           draw_text(x+1, y-1, width, height, text, align)
  48.         end
  49.         self.font.color = color_temp
  50.       end
  51.       #$OK = true
  52.       draw_text(x, y, width, height, text, align)
  53.     end
  54.   #end
  55. end
复制代码

作者: RyanBern    时间: 2014-11-1 20:56
原来的方法draw_text已经更名为sailcat_draw_text了,所以想要使用不加阴影的使用sailcat_draw_cat即可。如果改成参数的,似乎会有些困难。
作者: cinderelmini    时间: 2014-11-2 00:14
本帖最后由 cinderelmini 于 2014-11-2 00:22 编辑
  1. #======================================================================
  2. # 脚本来自[url]www.66rpg.com[/url],使用请保留此信息
  3. # 作者:SailCat;升级:柳柳;最后升级日期:2006年4月30日
  4. #======================================================================
  5. class Bitmap
  6.   unless $OK
  7.     alias sailcat_draw_text draw_text
  8.     def draw_text(p1, p2, p3 = 0, p4 = 3, p5 = nil, p6 = 0, p9 = false, p7 = 3, p8 = nil)
  9.       case p1
  10.       when Numeric
  11.         x = p1
  12.         y = p2
  13.         width = p3
  14.         height = p4
  15.         text = p5
  16.         align = p6
  17.         shadow_direction = p7
  18.         shadow_color = p8
  19.         if shadow_color.nil?
  20.           shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
  21.         end
  22.       when Rect
  23.         x = p1.x
  24.         y = p1.y
  25.         width = p1.width
  26.         height = p1.height
  27.         text = p2
  28.         align = p3
  29.         shadow_direction = p4
  30.         shadow_color = p5
  31.         if shadow_color.nil?
  32.           shadow_color = Color.new(0, 0, 0, self.font.color.alpha * 0.99)
  33.         end
  34.       end
  35.       if p9
  36.         sailcat_draw_text(x, y, width, height, text, align)
  37.         return
  38.       end
  39.       color_temp = self.font.color.clone
  40.       if shadow_direction != 0
  41.         self.font.color = shadow_color
  42.         case shadow_direction
  43.         when 1
  44.           sailcat_draw_text(x-1, y+1, width, height, text, align)
  45.         when 3
  46.           sailcat_draw_text(x+1, y+1, width, height, text, align)
  47.         when 7
  48.           sailcat_draw_text(x-1, y-1, width, height, text, align)
  49.         when 9
  50.           sailcat_draw_text(x+1, y-1, width, height, text, align)
  51.         end
  52.         self.font.color = color_temp
  53.       end
  54.       $OK = true
  55.       sailcat_draw_text(x, y, width, height, text, align)
  56.     end
  57.   end
  58. end
复制代码
把参数加上去了,
使用的话,比如
  1. self.contents.draw_text(x, y, width, height, text, align, 是否影子, 影子方向, 影子颜色)
复制代码
注:是否影子就是true/false,影子方向参考数字小键盘填对应数字,颜色填nil就是默认黑色(后面两者可不填)。
但是,改影子是否可见的话,必须填对齐(0/1/2→左/中/右)。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1