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

Project1

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

[已经过期] 如何把这个对话脚本改成逐字显示

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
49
在线时间
486 小时
注册时间
2009-7-23
帖子
449
跳转到指定楼层
1
发表于 2011-9-30 16:46:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
下面是脚本,我想改成逐字显示的...
  1. #原脚本来自66rpg.com,修改了头像半身像的显示位置,半身在对话框上,以及将左半身作为头像
  2. #\/不断行,下行继续
  3. #头像半身像位置Graphic\Heads\名字_h.png
  4. #改了闪动暂停图标的图形和位置,pause
  5. #——66的说明
  6. #默认为一个字一个字的方式,如果需要一次全部显示,
  7. #请在游戏中使用脚本:$game_system.typing = true      
  8. #默认对话字没有声音,如果需要声音,
  9. #请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  10. #我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音
  11. # 其他在对话中可以使用的功能:
  12. # \n[1]:显示1号角色的姓名
  13. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名
  14. # \p[1]:对话框出现在1号事件的上方
  15. # \p[0]:主人公上方出现对话框
  16. #——————————————————使用\p功能后可以自动调整对话框大小
  17. # \\:显示"\"这个符号
  18. # \c[1-8]:更改颜色
  19. # \g:显示金钱窗口
  20. # \a[SE文件名]:对话的时候播放SE
  21. # \s[1-19]:更改弹字的速度
  22. # \.   :停顿一刹那(1、2帧)
  23. # \|   :停顿片刻(20帧)
  24. # \>   :文字不用打字方式
  25. # \<   :文字使用打字方式
  26. # \!   :等待玩家按回车再继续
  27. # \~   :文字直接消失
  28. # \I   :下一行从这个位置开始
  29. # \o[123]:文字透明度改为123,模拟将死之人(汗)
  30. # \h[12]:改用12号字
  31. # \b[50]:空50象素
  32. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效
  33. # \L[001]:在左边显示图片“Graphics/Heads/001_h.png”
  34. # \R[001]:在右边显示图片“Graphics/Heads/001_h.png”
  35. # \Lk:清除左边的图像
  36. # \Rk:清除右边的图像

  37. # \g:显示金钱窗口
  38. # \t: 显示游戏时间窗口
  39. # \v[7]:显示7号变量的值
  40. # \v[a7]:显示7号防具的名称
  41. # \v[s7]:显示7号特技的名称
  42. # \v[w7]:显示7号武器的名称
  43. # \v[i7]:显示7号道具的名称

  44. # 补充:\/不断行
  45.   #==============================================================================
  46.   #  Sprite_Pause
  47.   #==============================================================================
  48. class Sprite_Pause < Sprite
  49.   def initialize
  50.     super
  51.     self.bitmap = RPG::Cache.windowskin("pause")
  52.     self.x = 570
  53.     self.y = 430
  54.     self.z = 9999
  55.     @count = 0
  56.     @wait_count = 0
  57.     update
  58.   end
  59.   def update
  60.     super
  61.     if @wait_count > 0
  62.       @wait_count -= 1
  63.     else
  64.       @count = (@count + 1)% 8
  65.       x = 30 * @count
  66.       self.src_rect.set(x, 0, 30, 20)
  67.       @wait_count = 2
  68.     end
  69.   end
  70. end
  71. #==============================================================================
  72. # ■ Window_Message
  73. #------------------------------------------------------------------------------
  74. class Window_Message < Window_Selectable
  75.   #--------------------------------------------------------------------------
  76.   # ● 初始化状态
  77.   #--------------------------------------------------------------------------
  78.   def initialize
  79.     super(80, 304, 500, 160)        
  80.     #AVG对话框图片背景
  81.     @back = Sprite.new
  82.     @back.bitmap = Bitmap.new("Graphics/Pictures/Message_back")
  83.     @back.opacity = 0
  84.     @back.x = 0
  85.     @back.y = 0
  86.     @back.z = 9998
  87.     self.contents = Bitmap.new(width - 222, height - 32)
  88.     self.visible = false
  89.     self.z = 9998
  90.     @fade_in = false
  91.     @fade_out = false
  92.     @contents_showing = false
  93.     @cursor_width = 0
  94.     self.active = false
  95.     self.index = -1
  96.     @opacity_text_buf = Bitmap.new(32, 32)
  97.     @pause = Sprite_Pause.new
  98.     @pause.visible = false
  99.   end
  100.   #--------------------------------------------------------------------------
  101.   # ● 释放
  102.   #--------------------------------------------------------------------------
  103.   def dispose
  104.     terminate_message
  105.     $game_temp.message_window_showing = false
  106.     if @input_number_window != nil
  107.       @input_number_window.dispose
  108.     end
  109.     @pause.dispose
  110.    
  111.     @back.dispose
  112.    
  113.     super
  114.   end
  115.   #--------------------------------------------------------------------------
  116.   # ● 处理信息结束
  117.   #--------------------------------------------------------------------------
  118.   def terminate_message
  119.     self.active = false
  120.     self.pause = false
  121.     self.index = -1
  122.     self.contents.clear
  123.     # 清除显示中标志
  124.     @contents_showing = false
  125.     # 呼叫信息调用
  126.     if $game_temp.message_proc != nil
  127.       $game_temp.message_proc.call
  128.     end
  129.     # 清除文章、选择项、输入数值的相关变量
  130.     $game_temp.message_text = nil
  131.     $game_temp.message_proc = nil
  132.     $game_temp.choice_start = 99
  133.     $game_temp.choice_max = 0
  134.     $game_temp.choice_cancel_type = 0
  135.     $game_temp.choice_proc = nil
  136.     $game_temp.num_input_start = 99
  137.     $game_temp.num_input_variable_id = 0
  138.     $game_temp.num_input_digits_max = 0
  139.     # 开放金钱窗口
  140.     if @gold_window != nil
  141.       @gold_window.dispose
  142.       @gold_window = nil
  143.     end
  144.     if @name_window_frame != nil
  145.       @name_window_frame.dispose
  146.       @name_window_frame = nil
  147.     end
  148.     if @name_window_text != nil
  149.       @name_window_text.dispose
  150.       @name_window_text = nil
  151.     end
  152.     if @right_picture != nil and @right_keep == true
  153.       @right_picture.dispose
  154.     end   
  155.     if @left_picture != nil and @left_keep == true
  156.       @left_picture.dispose
  157.     end
  158.   end
  159.   #--------------------------------------------------------------------------
  160. # ○ 一个一个描绘文字
  161. #--------------------------------------------------------------------------
  162. def refresh_drawtext
  163.    #........................................................................
  164.    if Input.trigger?(Input::C) and $game_switches[34]
  165.      # 循环信息描绘处理
  166.      while $game_temp.message_text != ""
  167.        draw_massage
  168.      end
  169.      draw_opt_text
  170.      @contents_showing_end = true
  171.      @contents_drawing = false
  172.    end
  173.    #........................................................................
  174.    if $game_temp.message_text != nil
  175.      if @wait > 0
  176.        @wait -= 1
  177.      elsif @wait == 0
  178.        # 描绘处理
  179.        draw_massage
  180.        @wait = $mes_speed
  181.      end
  182.    end
  183.    # 描绘结束
  184.    if $game_temp.message_text == ""
  185.      draw_opt_text
  186.      @contents_showing_end = true
  187.      @contents_drawing = false
  188.    end
  189. end
  190.   def refresh
  191.     # 初期化
  192.     self.contents.clear
  193.     self.contents.font.color = normal_color
  194.     self.contents.font.size = Font.default_size
  195.     @x = 0
  196.     @a = ""
  197.     @y = @max_x = @max_y = @indent = @lines = 0
  198.     @left_keep = @right_keep = false
  199.     @face_indent = 0
  200.     @opacity = 255
  201.     @cursor_width = 0
  202.     @refreshflag = true
  203.     centerflag = false
  204.     @write_speed = 0
  205.     @write_wait = 0
  206.     @mid_stop = false
  207.     @face_file = nil
  208.     @popchar = -2
  209.     if $game_temp.choice_start == 0
  210.       @x = 8
  211.     end
  212.     if $game_temp.message_text != nil
  213.       @now_text = $game_temp.message_text
  214.       #——头像设置
  215.       if (/\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  216.         @face_file = $1 + ".png"
  217.         @x = @face_indent = 128
  218.         if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  219.           self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  220.         end
  221.         @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  222.       end
  223.       #——左半身像设置
  224.       if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  225.         @face = $1 + ".png"
  226.         @x=@face_indent = 103
  227.         if $加密 == true
  228.           if @left_picture != nil
  229.             @left_picture.dispose
  230.           end
  231.           @left_picture = Sprite.new
  232.           @left_picture.bitmap = Bitmap.new("Graphics/Heads/#{@face}")
  233.           @left_picture.y = 459-@left_picture.bitmap.height
  234.           @left_picture.x = 13
  235.           @left_picture.z = 9999
  236.           @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  237.           @pause.x = 557
  238.         else         
  239.           if FileTest.exist?("Graphics/Heads/#{@face}")
  240.             if @left_picture != nil
  241.               @left_picture.dispose
  242.             end
  243.             @left_picture = Sprite.new
  244.             @left_picture.bitmap = Bitmap.new("Graphics/Heads/#{@face}")
  245.             @left_picture.y = 459-@left_picture.bitmap.height
  246.             @left_picture.x = 13
  247.             @left_picture.z = 9999
  248.             @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  249.             @pause.x = 557
  250.           end
  251.         end        
  252.       end
  253.       #——右半身像设置
  254.       if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  255.         @face = $1 + ".png"
  256.         if $加密 == true
  257.           if @right_picture != nil
  258.             @right_picture.dispose
  259.           end
  260.           @right_picture = Sprite.new
  261.           @right_picture.bitmap = Bitmap.new("Graphics/Heads/#{@face}")
  262.           @right_picture.y = 459-@right_picture.bitmap.height
  263.           @right_picture.x = 610-@right_picture.bitmap.width
  264.           @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  265.           @pause.x = 400
  266.         else
  267.           if FileTest.exist?("Graphics/Heads/#{@face}")
  268.             if @right_picture != nil
  269.               @right_picture.dispose
  270.             end
  271.             @x = @face_indent = 15
  272.             @right_picture = Sprite.new
  273.             @right_picture.bitmap = Bitmap.new("Graphics/Heads/#{@face}")
  274.             @right_picture.y = 459-@right_picture.bitmap.height
  275.             @right_picture.x = 610-@right_picture.bitmap.width
  276.             @right_picture.z = 9999
  277.                         @right_picture.mirror = true
  278.             @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  279.             @pause.x = 400
  280.           end
  281.         end
  282.       end
  283.       if (/\\[Rr]k/.match(@now_text)) != nil
  284.         @right_keep = true
  285.         @now_text.sub!(/\\[Rr]k/) { "" }
  286.       end
  287.       if (/\\[Ll]k/.match(@now_text)) != nil
  288.         @left_keep = true
  289.         @now_text.sub!(/\\[Ll]k/) { "" }
  290.       end
  291.       # 显示人物姓名
  292.       name_window_set = false
  293.       if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  294.         name_window_set = true
  295.         name_text = $1
  296.         @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  297.       end
  298.       
  299.       # 文字位置的判定
  300.       if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  301.         @popchar = $1.to_i
  302.         if @popchar == -1
  303.           @x = @indent = 48
  304.           @y = 4
  305.         end
  306.         @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  307.       end
  308.       
  309.       # 开始
  310.       begin
  311.         last_text = @now_text.clone
  312.         @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  313.       end until @now_text == last_text
  314.       @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  315.       $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  316.     end
  317.     @now_text.gsub!(/\\\\/) { "\000" }
  318.     @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  319.     @now_text.gsub!(/\\[Gg]/) { "\002" }
  320.     @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  321.     @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  322.     @now_text.gsub!(/\\[.]/) { "\005" }
  323.     @now_text.gsub!(/\\[|]/) { "\006" }

  324.     @now_text.gsub!(/\\[>]/) { "\016" }
  325.     @now_text.gsub!(/\\[<]/) { "\017" }
  326.     @now_text.gsub!(/\\[!]/) { "\020" }
  327.     @now_text.gsub!(/\\[~]/) { "\021" }
  328.    
  329.     @now_text.gsub!(/\\[Ii]/) { "\023" }
  330.     @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  331.     @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  332.     @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  333.     @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  334.          # "\\/" 删除行尾换行符号
  335.     @now_text.gsub!(/\\\/\n/) {""}
  336.      # 去掉不在行尾的"\\/"符号,防止出错
  337.     @now_text.gsub!(/\\\//) {""}
  338.     # 增加居中功能
  339.     @now_text.gsub!(/\\[Xx]/) { "\007" }
  340.      

  341.     if @popchar >= 0
  342.       @text_save = @now_text.clone
  343.       @max_x = 0
  344.       @max_y = 4
  345.       for i in 0..3
  346.         line = @now_text.split(/\n/)[3-i]
  347.         @max_y -= 1 if line == nil and @max_y <= 4-i
  348.         next if line == nil
  349.         cx = contents.text_size(line).width
  350.         @max_x = cx if cx > @max_x
  351.       end
  352.       self.width = @max_x + 48 + @face_indent
  353.       self.height = (@max_y - 1) * 32 + 64
  354.     else
  355.       @max_x = self.width - 32 - @face_indent
  356.     end
  357.     reset_window
  358.       if name_window_set
  359.         off_x = 0
  360.         off_y = -40
  361.         space = 2
  362.         x = self.x + off_x - space / 2
  363.         y = self.y + off_y - space / 2
  364.         w = self.contents.text_size(name_text).width + 26 + space
  365.         h = 40 + space
  366.         @name_window_frame = Window_Frame.new(x, y, w, h)
  367.         @name_window_frame.z = self.z + 1
  368.         x = self.x + off_x + 4
  369.         y = self.y + off_y
  370.         @name_window_text = Air_Text.new(x+4, y+6, name_text)
  371.         @name_window_text.z = self.z + 2
  372.       end
  373.     end
  374.     reset_window
  375.     if $game_temp.choice_max > 0
  376.       @item_max = $game_temp.choice_max
  377.       self.active = true
  378.       self.index = 0
  379.     end
  380.     if $game_temp.num_input_variable_id > 0
  381.       digits_max = $game_temp.num_input_digits_max
  382.       number = $game_variables[$game_temp.num_input_variable_id]
  383.       @input_number_window = Window_InputNumber.new(digits_max)
  384.       @input_number_window.number = number
  385.       @input_number_window.x = self.x + 8
  386.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  387.     end
  388.   end
  389.   #--------------------------------------------------------------------------
  390.   # ● 更新
  391.   #--------------------------------------------------------------------------
  392. def update
  393.         @pause.update if @pause.visible
  394.     super
  395.     if @fade_in
  396.       self.contents_opacity += 24
  397.       if @input_number_window != nil
  398.         @input_number_window.contents_opacity += 24
  399.       end
  400.       if self.contents_opacity == 255
  401.         @fade_in = false
  402.       end
  403.       return
  404.     end
  405.     @now_text = nil if @now_text == ""
  406.    
  407.     if @now_text != nil and @mid_stop == false
  408.       
  409.       if @write_wait > 0
  410.         @write_wait -= 1
  411.         return
  412.       end
  413.       while true
  414.         @max_x = @x if @max_x < @x
  415.         @max_y = @y if @max_y < @y
  416.         if (c = @now_text.slice!(/./m)) != nil
  417.           if c == "\000"
  418.             c = "\\"
  419.           end
  420.           if c == "\001"
  421.             @now_text.sub!(/\[([0-9]+)\]/, "")
  422.             color = $1.to_i
  423.             if color >= 0 and color <= 7
  424.               self.contents.font.color = text_color(color)
  425.             end
  426.             c = ""
  427.           end
  428.           if c == "\002"
  429.             if @gold_window == nil and @popchar <= 0
  430.               @gold_window = Window_Gold.new
  431.               @gold_window.x = 560 - @gold_window.width
  432.               if $game_temp.in_battle
  433.                 @gold_window.y = 192
  434.               else
  435.                 @gold_window.y = self.y >= 128 ? 32 : 384
  436.               end
  437.               @gold_window.opacity = self.opacity
  438.               @gold_window.back_opacity = self.back_opacity
  439.             end
  440.             c = ""
  441.           end
  442.           if c == "\003"
  443.             @now_text.sub!(/\[([0-9]+)\]/, "")
  444.             speed = $1.to_i
  445.             if speed >= 0 and speed <= 19
  446.               @write_speed = speed
  447.             end
  448.             c = ""
  449.           end
  450.           if c == "\004"
  451.             @now_text.sub!(/\[(.*?)\]/, "")
  452.             buftxt = $1.dup.to_s
  453.             if buftxt.match(/\//) == nil and buftxt != "" then
  454.               $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  455.             else
  456.               $game_system.soundname_on_speak = buftxt.dup
  457.             end
  458.             c = ""
  459.           elsif c == "\004"
  460.             c = ""
  461.           end
  462.           if c == "\005"
  463.             @write_wait += 5
  464.             c = ""
  465.           end
  466.           if c == "\006"
  467.             @write_wait += 20
  468.             c = ""
  469.           end
  470.           if c == "\007"
  471.           centerflag = true
  472.           next
  473.           end
  474.           if c == "\016"
  475.             text_not_skip = false
  476.             c = ""
  477.           end
  478.           if c == "\017"
  479.             text_not_skip = true
  480.             c = ""
  481.           end
  482.           if c == "\020"
  483.             @mid_stop = true
  484.             c = ""
  485.           end
  486.           if c == "\021"
  487.             terminate_message
  488.             return
  489.           end
  490.           if c == "\023"
  491.             @indent = @x
  492.             c = ""
  493.           end
  494.           if c == "\024"
  495.             @now_text.sub!(/\[([0-9]+)\]/, "")
  496.             @opacity = $1.to_i
  497.             c = ""
  498.           end
  499.           if c == "\025"
  500.             @now_text.sub!(/\[([0-9]+)\]/, "")
  501.             self.contents.font.size = [[$1.to_i, 6].max, 32].min
  502.             c = ""
  503.           end
  504.           if c == "\026"
  505.             @now_text.sub!(/\[([0-9]+)\]/, "")
  506.             @x += $1.to_i
  507.             c = ""
  508.           end
  509.           if c == "\027"
  510.             @now_text.sub!(/\[(.*?)\]/, "")
  511.             @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  512.             c = ""
  513.           end
  514.           if c == "\030"
  515.             @now_text.sub!(/\[(.*?)\]/, "")
  516.             self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  517.             @x += 24
  518.             c = ""
  519.           end
  520.           if c == "\n"
  521.           if centerflag == true
  522.             @x = 448 - @x
  523.             @x = @x / 2
  524.             self.contents.draw_text(@x, 32 * @y, 448-@x, line_height, c)
  525.           end
  526.           centerflag = false
  527.             if @lines >= $game_temp.choice_start
  528.               @cursor_width = [@cursor_width, @max_x - @face_indent].max
  529.             end
  530.             @lines += 1
  531.             @y += 1
  532.             @x = 0 + @indent + @face_indent
  533.             if @lines >= $game_temp.choice_start
  534.               @x = 8 + @indent + @face_indent
  535.             end
  536.             c = ""
  537.           end
  538.           if c != ""
  539.             # 文字描画
  540.             @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  541.           end
  542.           if Input.press?(Input::B)
  543.             text_not_skip = false
  544.           end
  545.         else
  546.           text_not_skip = true
  547.           break
  548.         end
  549.         # 終了判定
  550.         if text_not_skip
  551.           break
  552.         end
  553.       end
  554.       @write_wait += @write_speed
  555.       return
  556.     end
  557.     if @input_number_window != nil
  558.       @input_number_window.update
  559.       # 決定
  560.       if Input.trigger?(Input::C)
  561.         $game_system.se_play($data_system.decision_se)
  562.         $game_variables[$game_temp.num_input_variable_id] =
  563.         @input_number_window.number
  564.         $game_map.need_refresh = true
  565.         @input_number_window.dispose
  566.         @input_number_window = nil
  567.         terminate_message
  568.       end
  569.       return
  570.     end
  571.     if @contents_showing
  572.       if $game_temp.choice_max == 0
  573.                   #self.pause = true
  574.           @pause.visible = true
  575.       end
  576.       # 取消
  577.       if Input.trigger?(Input::B)
  578.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  579.           $game_system.se_play($data_system.cancel_se)
  580.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  581.           terminate_message
  582.                       @pause.visible = false
  583.         end
  584.       end
  585.       # 決定
  586.       if Input.trigger?(Input::C)
  587.         if $game_temp.choice_max > 0
  588.           $game_system.se_play($data_system.decision_se)
  589.           $game_temp.choice_proc.call(self.index)
  590.         end
  591.         if @mid_stop
  592.           @mid_stop = false
  593.           @pause.visible = false
  594.           return
  595.         else
  596.           terminate_message
  597.         end
  598.         @pause.visible = false
  599.       end
  600.       return
  601.     end
  602.     if @fade_out == false and $game_temp.message_text != nil
  603.       @contents_showing = true
  604.       $game_temp.message_window_showing = true
  605.       refresh
  606.       Graphics.frame_reset
  607.       self.visible = true
  608.       self.contents_opacity = 0
  609.     if @input_number_window != nil
  610.       @input_number_window.contents_opacity = 0
  611.     end
  612.       @fade_in = true
  613.       return
  614.     end
  615.     if self.visible
  616.       @fade_out = true
  617.       self.opacity -= 48
  618.       if self.opacity == 0
  619.         self.visible = false
  620.         @fade_out = false
  621.         $game_temp.message_window_showing = false
  622.         @back.opacity = 0
  623.       end
  624.       return
  625.     end
  626.   end
  627.   #--------------------------------------------------------------------------
  628.   # ● 获得字符
  629.   #--------------------------------------------------------------------------
  630.   def get_character(parameter)
  631.     case parameter
  632.     when 0
  633.       return $game_player
  634.     else
  635.       events = $game_map.events
  636.       return events == nil ? nil : events[parameter]
  637.     end
  638.   end
  639.   #--------------------------------------------------------------------------
  640.   # ● ウィンドウの位置と不透明度の設定
  641.   #--------------------------------------------------------------------------
  642.   def reset_window
  643.     # 判定
  644.     if @popchar >= 0
  645.       events = $game_map.events
  646.       if events != nil
  647.         character = get_character(@popchar)
  648.         x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  649.         y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  650.         self.x = x
  651.         self.y = y
  652.       end
  653.     elsif @popchar == -1
  654.       self.x = -4
  655.       self.y = -4
  656.       self.width = 648
  657.       self.height = 488
  658.     else
  659.       if $game_temp.in_battle
  660.         self.y = 16
  661.       else
  662.         if @face_file == nil
  663.           self.width = 600
  664.         else
  665.           self.x -= 20
  666.           self.width = 600
  667.         end
  668.         case $game_system.message_position
  669.         when 0 # 上
  670.           self.y = 16
  671.           self.height = 160
  672.           self.x=60
  673.         when 1 # 中
  674.           self.y = 160
  675.           self.height = 160
  676.           self.x=20
  677.         when 2 # 下
  678.           self.y = 315
  679.           self.height = 160
  680.           self.x=20
  681.         when 3
  682.           self.y = 0
  683.           self.x= 160
  684.           self.height = 480
  685.           self.width = 350
  686.         end
  687.       end
  688.     end
  689.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  690.     if @face_file != nil
  691.       self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  692.     end
  693.     if @popchar == -1
  694.       self.opacity = 0
  695.       self.back_opacity = 0
  696.       @back.opacity = 0
  697.     elsif $game_system.message_frame == 0
  698.       self.opacity = 0
  699.       self.back_opacity = 0
  700.       @back.opacity = 255
  701.       if $game_system.message_position == 3
  702.         self.back_opacity = 0
  703.         @back.opacity = 120
  704.       end
  705.     else
  706.       self.opacity = 0
  707.       self.back_opacity = 200
  708.     end
  709.   end
  710.   #--------------------------------------------------------------------------
  711.   # ● line_height
  712.   #--------------------------------------------------------------------------
  713.   # 返回値:行高
  714.   #--------------------------------------------------------------------------
  715.   def line_height
  716.     return 30
  717.     if self.contents.font.size >= 20 and self.contents.font.size <= 24
  718.       return 30
  719.     else
  720.       return self.contents.font.size * 15 / 10
  721.     end
  722.   end
  723.   #--------------------------------------------------------------------------
  724.   # ● 透過文字描画
  725.   #--------------------------------------------------------------------------
  726.   # target :描画対象。Bitmapクラスを指定。
  727.   # x :x座標
  728.   # y :y座標
  729.   # str  :描画文字列
  730.   # opacity:透過率(0~255)
  731.   # 返回値 :文字幅(@x増加値)。
  732.   #--------------------------------------------------------------------------
  733.   def opacity_draw_text(target, x, y, str,opacity)
  734.     height = target.font.size
  735.     width = target.text_size(str).width
  736.     opacity = [[opacity, 0].max, 255].min
  737.     if opacity == 255
  738.       target.draw_text(x, y, width, height, str)
  739.       return width
  740.     else
  741.       if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  742.         @opacity_text_buf.dispose
  743.         @opacity_text_buf = Bitmap.new(width, height)
  744.       else
  745.         @opacity_text_buf.clear
  746.       end
  747.       @opacity_text_buf.font.size = target.font.size
  748.       @opacity_text_buf.draw_text(0, 0, width, height, str)
  749.       target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  750.     return width
  751.     end
  752.   end
  753.   def ruby_draw_text(target, x, y, str,opacity)
  754.     sizeback = target.font.size
  755.     target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  756.     rubysize = [rubysize, 6].max
  757.    
  758.     opacity = [[opacity, 0].max, 255].min
  759.     split_s = str.split(/,/)
  760.    
  761.     split_s[0] == nil ? split_s[0] = "" : nil
  762.     split_s[1] == nil ? split_s[1] = "" : nil
  763.    
  764.     height = sizeback + rubysize
  765.     width = target.text_size(split_s[0]).width
  766.    
  767.     target.font.size = rubysize
  768.     ruby_width = target.text_size(split_s[1]).width
  769.     target.font.size = sizeback
  770.    
  771.     buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  772.    
  773.     width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  774.    
  775.     if opacity == 255
  776.       target.font.size = rubysize
  777.       target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  778.       target.font.size = sizeback
  779.       target.draw_text(x, y, width, target.font.size, split_s[0])
  780.       return width
  781.     else
  782.       if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  783.         @opacity_text_buf.dispose
  784.         @opacity_text_buf = Bitmap.new(buf_width, height)
  785.       else
  786.         @opacity_text_buf.clear
  787.       end
  788.       @opacity_text_buf.font.size = rubysize
  789.       @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  790.       @opacity_text_buf.font.size = sizeback
  791.       @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  792.       if sub_x >= 0
  793.         target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  794.       else
  795.         target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  796.       end
  797.       return width
  798.     end
  799.   end
  800.   #--------------------------------------------------------------------------
  801.   # ● \V 变换
  802.   #--------------------------------------------------------------------------
  803.   def convart_value(option, index)
  804.     option == nil ? option = "" : nil
  805.     option.downcase!
  806.     case option
  807.       when "i"
  808.         unless $data_items[index].name == nil
  809.           r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  810.         end
  811.       when "w"
  812.         unless $data_weapons[index].name == nil
  813.           r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  814.         end
  815.       when "a"
  816.         unless $data_armors[index].name == nil
  817.           r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  818.         end
  819.       when "s"
  820.         unless $data_skills[index].name == nil
  821.           r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  822.         end
  823.       else
  824.       r = $game_variables[index]
  825.     end
  826.     r == nil ? r = "" : nil
  827.     return r
  828.   end
  829.   #--------------------------------------------------------------------------
  830.   # ● 解放
  831.   #--------------------------------------------------------------------------
  832.   def dispose
  833.     terminate_message
  834.     if @gaiji_cache != nil
  835.       unless @gaiji_cache.disposed?
  836.         @gaiji_cache.dispose
  837.       end
  838.     end
  839.     unless @opacity_text_buf.disposed?
  840.       @opacity_text_buf.dispose
  841.     end
  842.     $game_temp.message_window_showing = false
  843.     if @input_number_window != nil
  844.       @input_number_window.dispose
  845.     end
  846.     super
  847.   end
  848.   #--------------------------------------------------------------------------
  849.   # ● 矩形更新
  850.   #--------------------------------------------------------------------------
  851.   def update_cursor_rect
  852.     if @index >= 0
  853.       n = $game_temp.choice_start + @index
  854.       self.cursor_rect.set(4 + @indent + @face_indent, n * 30 + 10, @cursor_width, 25)
  855.     else
  856.       self.cursor_rect.empty
  857.     end
  858.   end
  859. end
  860. #==============================================================================
  861. # ■ Window_Frame (枠だけで中身の無いウィンドウ)
  862. #==============================================================================
  863. class Window_Frame < Window_Base
  864.   #--------------------------------------------------------------------------
  865.   # ● オブジェクト初期化
  866.   #--------------------------------------------------------------------------
  867.   def initialize(x, y, width, height)
  868.     super(x, y, width, height)
  869.     self.contents = nil
  870.     self.back_opacity = 200
  871.   end
  872.   #--------------------------------------------------------------------------
  873.   # ● 解放
  874.   #--------------------------------------------------------------------------
  875.   def dispose
  876.     super
  877.     @back.opacity = 0
  878.     end
  879.   end
  880. #==============================================================================
  881. # ■ Air_Text (何も無いところに文字描写 = 枠の無い瞬間表示メッセージウィンドウ)
  882. #==============================================================================
  883. class Air_Text < Window_Base
  884.   #--------------------------------------------------------------------------
  885.   # ● オブジェクト初期化
  886.   #--------------------------------------------------------------------------
  887.   def initialize(x, y, designate_text)
  888.     super(x-16, y-16, 32 + designate_text.size * 12, 56)
  889.     self.opacity = 0
  890.     self.back_opacity = 0
  891.     self.contents = Bitmap.new(self.width - 32, self.height - 32)
  892.     w = self.contents.width
  893.     h = self.contents.height
  894.     self.contents.draw_text(0, 0, w, h, designate_text)
  895.   end
  896.   #--------------------------------------------------------------------------
  897.   # ● 解放
  898.   #--------------------------------------------------------------------------
  899.   def dispose
  900.     self.contents.clear
  901.     super
  902.   end
  903. end
复制代码

评分

参与人数 1星屑 +800 收起 理由
「旅」 + 800 补回积分~

查看全部评分

Lv3.寻梦者

永久的旅行者

梦石
1
星屑
110
在线时间
404 小时
注册时间
2006-12-13
帖子
3091

开拓者贵宾第3届短篇游戏大赛主流游戏组季军第5届短篇游戏比赛季军

2
发表于 2011-9-30 17:05:13 | 只看该作者
脚本最前的几行有这么两句...
  1. #默认为一个字一个字的方式,如果需要一次全部显示,
  2. #请在游戏中使用脚本:$game_system.typing = true
复制代码
是你要的效果吗?

点评

执行脚本发生NoMethodError  发表于 2011-9-30 17:12
回复

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
136 小时
注册时间
2011-8-15
帖子
321
3
发表于 2011-9-30 17:43:02 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

Lv2.观梦者

梦石
0
星屑
432
在线时间
4175 小时
注册时间
2010-6-26
帖子
6474
4
发表于 2011-10-12 11:14:59 | 只看该作者
太简单了,那个变量$mes_speed为0的时候就不能一个字一个字显示。我有个帖子是关于FUKI的
只要在游戏事件对脚本赋值就可以了例如
$mes_speed = 1
潜水,专心忙活三次元工作了……
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-2 11:28

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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