设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1016|回复: 4
打印 上一主题 下一主题

如何在对话中添加多种颜色(排除默认的那几种!)

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1 小时
注册时间
2007-7-25
帖子
88
跳转到指定楼层
1
发表于 2008-5-18 02:46:44 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
如何在显示文章中,可以使用更多的自定义颜色?
而不总是只有那几个颜色可选。
帮忙下,谢谢了!
版务信息:版主帮忙结贴~
HELLO!我是幻世剑侠! 欢迎大家来我的百度空间踩踩吧!~ http://hi.baidu.com/%BB%C3%CA%C0%BD%A3%CF%C0

Lv1.梦旅人

梦石
0
星屑
50
在线时间
93 小时
注册时间
2008-5-16
帖子
745
2
发表于 2008-5-18 02:51:23 | 只看该作者
class Window_Base < Window
def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      normal_color
    end
  end
end


默认7种颜色,我们可以这样加,然后就可以这样用 \c[8]
class Window_Base < Window
def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    when 8
      return Color.new(5, 32, 12, 155) #后面4个数值就是颜色的变化
    else
      normal_color
    end
  end
end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
93 小时
注册时间
2008-5-16
帖子
745
3
发表于 2008-5-18 02:54:52 | 只看该作者
然后我们还要改一下Window_Message里的判断
class Window_Message < Window_Selectable
def refresh
    self.contents.clear
    self.contents.font.color = normal_color
    x = y = 0
    @cursor_width = 0
    # 到选择项的下一行字
    if $game_temp.choice_start == 0
      x = 8
    end
    # 有等待显示的文字的情况下
    if $game_temp.message_text != nil
      text = $game_temp.message_text
      # 限制文字处理
      begin
        last_text = text.clone
        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
      end until text == last_text
      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
      end
      # 为了方便、将 "\\\\" 变换为 "\000"
      text.gsub!(/\\\\/) { "\000" }
      # "\\C" 变为 "\001" に、"\\G" 变为 "\002"
      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
      text.gsub!(/\\[Gg]/) { "\002" }
      # c 获取 1 个字 (如果不能取得文字就循环)
      while ((c = text.slice!(/./m)) != nil)
        # \\ 的情况下
        if c == "\000"
          # 还原为本来的文字
          c = "\\"
        end
        # \C[n] 的情况下
        if c == "\001"
          # 更改文字色
          text.sub!(/\[([0-9]+)\]/, "")
          color = $1.to_i
          if color >= 0 and color <= 8
            self.contents.font.color = text_color(color)
          end
          # 下面的文字
          next
        end
        # \G 的情况下
        if c == "\002"
          # 生成金钱窗口
          if @gold_window == nil
            @gold_window = Window_Gold.new
            @gold_window.x = 560 - @gold_window.width
            if $game_temp.in_battle
              @gold_window.y = 192
            else
              @gold_window.y = self.y >= 128 ? 32 : 384
            end
            @gold_window.opacity = self.opacity
            @gold_window.back_opacity = self.back_opacity
          end
          # 下面的文字
          next
        end
        # 另起一行文字的情况下
        if c == "\n"
          # 刷新选择项及光标的高
          if y >= $game_temp.choice_start
            @cursor_width = [@cursor_width, x].max
          end
          # y 加 1
          y += 1
          x = 0
          # 移动到选择项的下一行
          if y >= $game_temp.choice_start
            x = 8
          end
          # 下面的文字
          next
        end
        # 描绘文字
        self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
        # x 为要描绘文字的加法运算
        x += self.contents.text_size(c).width
      end
    end
    # 选择项的情况
    if $game_temp.choice_max > 0
      @item_max = $game_temp.choice_max
      self.active = true
      self.index = 0
    end
    # 输入数值的情况
    if $game_temp.num_input_variable_id > 0
      digits_max = $game_temp.num_input_digits_max
      number = $game_variables[$game_temp.num_input_variable_id]
      @input_number_window = Window_InputNumber.new(digits_max)
      @input_number_window.number = number
      @input_number_window.x = self.x + 8
      @input_number_window.y = self.y + $game_temp.num_input_start * 32
    end
  end
end
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
142
在线时间
264 小时
注册时间
2006-11-22
帖子
1057
4
发表于 2008-5-18 02:57:55 | 只看该作者
增加一个when 8,如想用更多颜色,增加when 9,如此类推。
class Window_Base < Window
def text_color(n)
   case n
   when 0
     return Color.new(255, 255, 255, 255)
   when 1
     return Color.new(128, 128, 255, 255)
   when 2
     return Color.new(255, 128, 128, 255)
   when 3
     return Color.new(128, 255, 128, 255)
   when 4
     return Color.new(128, 255, 255, 255)
   when 5
     return Color.new(255, 128, 255, 255)
   when 6
     return Color.new(255, 255, 128, 255)
   when 7
     return Color.new(192, 192, 192, 255)
   when 8
     return Color.new(35, 255, 195, 255)
   else
     normal_color
   end
end
end

Window_Message也要改,按CTRL+F搜索if color >= 0 and color <= 7,改成if color >= 0 and color <= 99。
系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
93 小时
注册时间
2008-5-16
帖子
745
5
发表于 2008-5-18 02:59:08 | 只看该作者
  1. class Window_Base < Window
  2. def text_color(n)
  3.    case n
  4.    when 0
  5.      return Color.new(255, 255, 255, 255)
  6.    when 1
  7.      return Color.new(128, 128, 255, 255)
  8.    when 2
  9.      return Color.new(255, 128, 128, 255)
  10.    when 3
  11.      return Color.new(128, 255, 128, 255)
  12.    when 4
  13.      return Color.new(128, 255, 255, 255)
  14.    when 5
  15.      return Color.new(255, 128, 255, 255)
  16.    when 6
  17.      return Color.new(255, 255, 128, 255)
  18.    when 7
  19.      return Color.new(192, 192, 192, 255)
  20.   ### 增加的
  21.    when 8
  22.      return Color.new(5, 32, 12, 155)
  23.    when 9
  24.     return Color.new(50, 132, 12, 155)
  25.    when 10
  26.     return Color.new(55, 200, 12, 55)
  27.   ### 增加的
  28.   #当然还可以 #
  29.   # when 11
  30.   # return Color.new(x,x,x,x)
  31.   # 然后下面的判断也改为11
  32.    else
  33.      normal_color
  34.    end
  35. end
  36. end
  37. class Window_Message < Window_Selectable
  38. def refresh
  39.    self.contents.clear
  40.    self.contents.font.color = normal_color
  41.    x = y = 0
  42.    @cursor_width = 0
  43.    # 到选择项的下一行字
  44.    if $game_temp.choice_start == 0
  45.      x = 8
  46.    end
  47.    # 有等待显示的文字的情况下
  48.    if $game_temp.message_text != nil
  49.      text = $game_temp.message_text
  50.      # 限制文字处理
  51.      begin
  52.        last_text = text.clone
  53.        text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  54.      end until text == last_text
  55.      text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  56.        $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  57.      end
  58.      # 为了方便、将 "\\\\" 变换为 "\000"
  59.      text.gsub!(/\\\\/) { "\000" }
  60.      # "\\C" 变为 "\001" に、"\\G" 变为 "\002"
  61.      text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  62.      text.gsub!(/\\[Gg]/) { "\002" }
  63.      # c 获取 1 个字 (如果不能取得文字就循环)
  64.      while ((c = text.slice!(/./m)) != nil)
  65.        # \\ 的情况下
  66.        if c == "\000"
  67.          # 还原为本来的文字
  68.          c = "\\"
  69.        end
  70.        # \C[n] 的情况下
  71.        if c == "\001"
  72.          # 更改文字色
  73.          text.sub!(/\[([0-9]+)\]/, "")
  74.          color = $1.to_i
  75.          ##################
  76.                   ##################
  77.                            ##################
  78.                            # 若有10个数字选择就10 其他也是
  79.          if color >= 0 and color <= 10
  80.            self.contents.font.color = text_color(color)
  81.          end
  82.          # 下面的文字
  83.          next
  84.        end
  85.        # \G 的情况下
  86.        if c == "\002"
  87.          # 生成金钱窗口
  88.          if @gold_window == nil
  89.            @gold_window = Window_Gold.new
  90.            @gold_window.x = 560 - @gold_window.width
  91.            if $game_temp.in_battle
  92.              @gold_window.y = 192
  93.            else
  94.              @gold_window.y = self.y >= 128 ? 32 : 384
  95.            end
  96.            @gold_window.opacity = self.opacity
  97.            @gold_window.back_opacity = self.back_opacity
  98.          end
  99.          # 下面的文字
  100.          next
  101.        end
  102.        # 另起一行文字的情况下
  103.        if c == "\n"
  104.          # 刷新选择项及光标的高
  105.          if y >= $game_temp.choice_start
  106.            @cursor_width = [@cursor_width, x].max
  107.          end
  108.          # y 加 1
  109.          y += 1
  110.          x = 0
  111.          # 移动到选择项的下一行
  112.          if y >= $game_temp.choice_start
  113.            x = 8
  114.          end
  115.          # 下面的文字
  116.          next
  117.        end
  118.        # 描绘文字
  119.        self.contents.draw_text(4 + x, 32 * y, 40, 32, c)
  120.        # x 为要描绘文字的加法运算
  121.        x += self.contents.text_size(c).width
  122.      end
  123.    end
  124.    # 选择项的情况
  125.    if $game_temp.choice_max > 0
  126.      @item_max = $game_temp.choice_max
  127.      self.active = true
  128.      self.index = 0
  129.    end
  130.    # 输入数值的情况
  131.    if $game_temp.num_input_variable_id > 0
  132.      digits_max = $game_temp.num_input_digits_max
  133.      number = $game_variables[$game_temp.num_input_variable_id]
  134.      @input_number_window = Window_InputNumber.new(digits_max)
  135.      @input_number_window.number = number
  136.      @input_number_window.x = self.x + 8
  137.      @input_number_window.y = self.y + $game_temp.num_input_start * 32
  138.    end
  139. end
  140. end
复制代码

写好的脚本 你可以用
\c[8到10的数字]调用
当然在编辑中无法看出字体颜色要进入游戏后!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-7-29 22:46

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表