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

Project1

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

[已经过期] 对话框及等待符号脚本改正

[复制链接]

Lv1.梦旅人

梦石
0
星屑
161
在线时间
38 小时
注册时间
2012-6-16
帖子
77
跳转到指定楼层
1
发表于 2014-8-5 19:30:45 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Message
  3. #------------------------------------------------------------------------------
  4. #  显示文章的信息窗口。
  5. #==============================================================================
  6.  
  7. class Window_Message < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化状态
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(80, 304, 480, 160)
  13.     self.contents = Bitmap.new(width - 32,height - 32)
  14.     self.visible = false
  15.     self.z = 0
  16.     self.windowskin = Bitmap.new(1,1)
  17.     @fade_in = false
  18.     @fade_out = false
  19.     @contents_showing = false
  20.     @cursor_width = 0
  21.     @wait_bmp = Sprite.new
  22.     @wait_bmp.z = 9999
  23.     @wait_bmp.bitmap = Bitmap.new(40,40)
  24.     [url=home.php?mod=space&uid=346374]@head[/url] = Sprite.new
  25.     @head.x = -30
  26.     @head.y = 349
  27.     @head.z = 9999
  28.     [url=home.php?mod=space&uid=36110]@Wait[/url] = 0
  29.     [url=home.php?mod=space&uid=32215]@show[/url] = 0
  30.     @bmp = nil
  31.     self.active = false
  32.     self.index = -1
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 释放
  36.   #--------------------------------------------------------------------------
  37.   def dispose
  38.     terminate_message
  39.     $game_temp.message_window_showing = false
  40.     if @input_number_window != nil
  41.       @input_number_window.dispose
  42.     end
  43.     @wait_bmp.bitmap.dispose
  44.     @wait_bmp.dispose
  45.     @head.dispose
  46.     @bmp.dispose if @bmp!=nil
  47.     super
  48.   end
  49.   #--------------------------------------------------------------------------
  50.   # ● 处理信息结束
  51.   #--------------------------------------------------------------------------
  52.   def terminate_message
  53.     self.active = false
  54.     self.pause = false
  55.     self.index = -1
  56.     self.contents.clear
  57.     @wait_bmp.bitmap.clear
  58.     # 清除显示中标志
  59.     @contents_showing = false
  60.     # 呼叫信息调用
  61.     if $game_temp.message_proc != nil
  62.       $game_temp.message_proc.call
  63.     end
  64.     # 清除文章、选择项、输入数值的相关变量
  65.     $game_temp.message_text = nil
  66.     $game_temp.message_proc = nil
  67.     $game_temp.choice_start = 99
  68.     $game_temp.choice_max = 0
  69.     $game_temp.choice_cancel_type = 0
  70.     $game_temp.choice_proc = nil
  71.     $game_temp.num_input_start = 99
  72.     $game_temp.num_input_variable_id = 0
  73.     $game_temp.num_input_digits_max = 0
  74.     # 开放金钱窗口
  75.     if @gold_window != nil
  76.       @gold_window.dispose
  77.       @gold_window = nil
  78.     end
  79.     if @head.bitmap != nil
  80.        @head.bitmap.dispose
  81.        end
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # ● 刷新
  85.   #--------------------------------------------------------------------------
  86.   def refresh
  87.     @message_x = 0
  88.     self.contents.clear
  89.     self.contents.fill_rect(0,0,width - 32,height,Color.new(0,0,0,120))
  90.     self.contents.font.color = normal_color
  91.     y = 0
  92.     x =@message_x
  93.     @cursor_width = 0
  94.     # 到选择项的下一行字
  95.     if $game_temp.choice_start == 0
  96.       x = 8
  97.     end
  98.     # 有等待显示的文字的情况下
  99.     if $game_temp.message_text != nil
  100.       text = $game_temp.message_text
  101.       # 限制文字处理
  102.       begin
  103.         last_text = text.clone
  104.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  105.       end until text == last_text
  106.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  107.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  108.       end
  109.       # 为了方便、将 "\\\\" 变换为 "\000"
  110.       text.gsub!(/\\\\/) { "\000" }
  111.       # "\\C" 变为 "\001" 、"\\G" 变为 "\002"
  112.       text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  113.       text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\003[#{$1}]" }
  114.       if $1 != nil
  115.       head = $1.to_s
  116.       @head.bitmap = Bitmap.new("Graphics/#{head}_b")
  117.       text.gsub!(/\003\[([0-9]+)\]/) { "" }
  118.       @message_x = 35
  119.       end
  120.       text.gsub!(/\\[Gg]/) { "\002" }
  121.       x = @message_x
  122.       # c 获取 1 个字 (如果不能取得文字就循环)
  123.       while ((c = text.slice!(/./m)) != nil)
  124.         # \\ 的情况下
  125.         if c == "\000"
  126.           # 还原为本来的文字
  127.           c = "\\"
  128.         end
  129.         # \C[n] 的情况下
  130.         if c == "\001"
  131.           # 更改文字色
  132.           text.sub!(/\[([0-9]+)\]/, "")
  133.           color = $1.to_i
  134.           if color >= 0 and color <= 7
  135.             self.contents.font.color = text_color(color)
  136.           end
  137.           # 下面的文字
  138.           next
  139.         end
  140.         # \G 的情况下
  141.         if c == "\002"
  142.           # 生成金钱窗口
  143.           if @gold_window == nil
  144.             @gold_window = Window_Gold.new
  145.             @gold_window.x = 560 - @gold_window.width
  146.             if $game_temp.in_battle
  147.               @gold_window.y = 192
  148.             else
  149.               @gold_window.y = self.y >= 128 ? 32 : 384
  150.             end
  151.             @gold_window.opacity = self.opacity
  152.             @gold_window.back_opacity = self.back_opacity
  153.           end
  154.           # 下面的文字
  155.           next
  156.         end
  157.         # 另起一行文字的情况下
  158.         if c == "\n"
  159.           # 刷新选择项及光标的高
  160.           if y >= $game_temp.choice_start
  161.             @cursor_width = [@cursor_width, x].max
  162.           end
  163.           # y 加 1
  164.           y += 1
  165.           x = @message_x
  166.           # 移动到选择项的下一行
  167.           if y >= $game_temp.choice_start
  168.             x = 8
  169.           end
  170.           # 下面的文字
  171.           next
  172.         end
  173.         # 描绘文字
  174.         self.contents.draw_text(4 + x, 32 * y+32, 40, 32, c)
  175.         # x 为要描绘文字的加法运算
  176.         x += self.contents.text_size(c).width
  177.       end
  178.     end
  179.     # 选择项的情况
  180.     if $game_temp.choice_max > 0
  181.       @item_max = $game_temp.choice_max
  182.       self.active = true
  183.       self.index = 0
  184.     end
  185.     # 输入数值的情况
  186.     if $game_temp.num_input_variable_id > 0
  187.       digits_max = $game_temp.num_input_digits_max
  188.       number = $game_variables[$game_temp.num_input_variable_id]
  189.       @input_number_window = Window_InputNumber.new(digits_max)
  190.       @input_number_window.number = number
  191.       @input_number_window.x = self.x + 8
  192.       @input_number_window.y = self.y + $game_temp.num_input_start * 32
  193.     end
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ● 设置窗口位置与不透明度
  197.   #--------------------------------------------------------------------------
  198.   def reset_window
  199.     if $game_temp.in_battle
  200.       self.y = 16
  201.     else
  202.       case $game_system.message_position
  203.       when 0  # 上
  204.         self.y = 16
  205.       when 1  # 中
  206.         self.y = 160
  207.       when 2  # 下
  208.         self.y = 304
  209.       end
  210.     end
  211.     if $game_system.message_frame == 0
  212.       self.opacity = 255
  213.     else
  214.       self.opacity = 0
  215.     end
  216.     self.back_opacity = 160
  217.   end
  218.   #--------------------------------------------------------------------------
  219.   # ● 刷新画面
  220.   #--------------------------------------------------------------------------
  221.   def update
  222.     super
  223.     # 渐变的情况下
  224.     if @fade_in
  225.       self.contents_opacity += 24
  226.       if @input_number_window != nil
  227.         @input_number_window.contents_opacity += 24
  228.       end
  229.       @head.x = 2
  230.        if self.contents_opacity == 255
  231.         @fade_in = false
  232.       end
  233.       return
  234.     end
  235.     # 输入数值的情况下
  236.     if @input_number_window != nil
  237.       @input_number_window.update
  238.       # 确定
  239.       if Input.trigger?(Input::C)
  240.         $game_system.se_play($data_system.decision_se)
  241.         $game_variables[$game_temp.num_input_variable_id] =
  242.           @input_number_window.number
  243.         $game_map.need_refresh = true
  244.         # 释放输入数值窗口
  245.         @input_number_window.dispose
  246.         @input_number_window = nil
  247.         terminate_message
  248.       end
  249.       return
  250.     end
  251.     # 显示信息中的情况下
  252.     if @contents_showing
  253.       # 如果不是在显示选择项中就显示暂停标志
  254.       if $game_temp.choice_max == 0
  255.         self.pause = true
  256.       end
  257.       # 取消
  258.       if Input.trigger?(Input::B)
  259.         if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  260.           $game_system.se_play($data_system.cancel_se)
  261.           $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  262.           terminate_message
  263.         end
  264.       end
  265.       # 确定
  266.       if Input.trigger?(Input::C)
  267.         if $game_temp.choice_max > 0
  268.           $game_system.se_play($data_system.decision_se)
  269.           $game_temp.choice_proc.call(self.index)
  270.         end
  271.         terminate_message
  272.       end
  273.      if @bmp == nil
  274.       @bmp = RPG::Cache.windowskin("d.png")
  275.       end
  276.       if @wait_bmp.y != self.y + 100
  277.         @wait_bmp.x = self.x + 420
  278.         @wait_bmp.y = self.y + 100
  279.       end
  280.       if @wait % 7 == 0
  281.        @show +=1
  282.        rect = Rect.new(@bmp.width/4 * (@show % 4),0,@bmp.width / 4,@bmp.height)
  283.        @wait_bmp.bitmap.clear
  284.        @wait_bmp.bitmap.blt(0,0,@bmp,rect)
  285.      end
  286.      @wait +=1
  287.       return
  288.     end
  289.     # 在渐变以外的状态下有等待显示的信息与选择项的场合
  290.     if @fade_out == false and $game_temp.message_text != nil
  291.       @contents_showing = true
  292.       $game_temp.message_window_showing = true
  293.       reset_window
  294.       refresh
  295.       Graphics.frame_reset
  296.       self.visible = true
  297.       self.contents_opacity = 0
  298.       if @input_number_window != nil
  299.         @input_number_window.contents_opacity = 0
  300.       end
  301.       @fade_in = true
  302.       return
  303.     end
  304.     # 没有可以显示的信息、但是窗口为可见的情况下
  305.     if self.visible
  306.       @fade_out = true
  307.       self.opacity -= 48
  308.       if self.opacity == 0
  309.         self.visible = false
  310.         @fade_out = false
  311.         $game_temp.message_window_showing = false
  312.       end
  313.       return
  314.     end
  315.   end
  316.   #--------------------------------------------------------------------------
  317.   # ● 刷新光标矩形
  318.   #--------------------------------------------------------------------------
  319.   def update_cursor_rect
  320.     if @index >= 0
  321.       n = $game_temp.choice_start + @index
  322.       self.cursor_rect.set(8, n * 32, @cursor_width, 32)
  323.     else
  324.       self.cursor_rect.empty
  325.     end
  326.   end
  327. end

对RM中原来的Message根据教程进行了改变,但遇到三个问题:1、怎么把自己绘制的对话框变成一般高级RPG游戏那样在宽上撑满一个屏幕?2、等待自己绘制的光标貌似不管怎么改z值都在自己绘制的对话框下,如何改正?3、如果想让自己绘制的对话框有一种渐变色的效果可以怎么办?
主要是前2个问题较急,求解决!

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
2
发表于 2014-8-6 22:11:25 | 只看该作者
1.super(x, y, 宽度, 高度) 你现在的宽度是480
2.self.contents.blt 绝对不会有这种问题
3.要么改素材要么填矩形

点评

self.contents.blt如何使用?  发表于 2014-8-10 09:49
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-15 20:59

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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