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

Project1

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

[推荐问答] 怎么在对话时加图片啊

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2012-7-28
帖子
63
跳转到指定楼层
1
发表于 2012-8-1 13:33:51 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 心倾河中 于 2012-8-1 13:34 编辑

我想在对话时加人物图片,可弄不明白。谁能教教我吗?

Lv1.梦旅人

梦石
0
星屑
55
在线时间
85 小时
注册时间
2012-4-25
帖子
192
2
发表于 2012-8-1 14:29:35 | 只看该作者
本帖最后由 hcm 于 2012-8-11 13:35 编辑

问题不明确哟。

你是想在对话框里的左边加入角色图片是么?
你的对话框脚本是默认还是别的呢。
默认的话是不能加入图片的哟,除非你用的是vx或者va

我给你一个对话框脚本
  1. #   1. 此脚本主要是解决了在1.03版XP上的方块问题,以及增加了一些功能
  2. #
  3. #   2. 人名美化使用方法与以前一样
  4. #
  5. #   3. 默认人物头像在左边显示
  6. #      如果需要右边显示,在输入的名称之后加"@r"即可
  7. #      例: "阿尔西斯@r:"(注意必须小写)
  8. #
  9. #   4. 在对话中更改字体的方法:
  10. #       \f[X]:更改字号为X
  11. #
  12. #   5. 在对话中显示(技能 物品 武器 防具 人物)图标和名称的方法:
  13. #       \s[X]: 显示第X号技能图标和名称
  14. #       \i[X]: 显示第X号物品图标和名称
  15. #       \w[X]: 显示第X号武器图标和名称
  16. #       \a[X]: 显示第X号防具图标和名称
  17. #       \r[X]: 显示第X号人物图标和名称
  18. #
  19. #   6. 在对话中更改文字不透明度的方法:
  20. #       \o[X]: 把文字不透明度更改为X (取值范围为0~255)
  21. #   
  22. #   7. 在对话中关闭或开启拟声音效的方法:
  23. #       \q:默认开启时,执行一次关闭,再执行一次则开启
  24. #
  25. #   8. 如果需要自定义字体颜色,
  26. #       可以打开"Graphics/Windowskins"目录下的"Window.png"文件查看
  27. #       使用方法与VX类似
  28. #
  29. # 素材要求:
  30. #   1. 要求所有半身像朝向一致(默认是正面偏右)
  31. #
  32. #--------------------------------------------------------------------------
  33. # ● 参数设置
  34. #--------------------------------------------------------------------------
  35. # 预设字体组
  36.   FONT_ARRAY = ["黑体", "宋体", "仿宋_GB2312"]
  37. # 控制显示尾部图标的开关号
  38.   TAIL_SHOW  = true
  39. # 头像图片保存目录的设定
  40.   FACE_PIC_DIR = "Graphics/Faces/"
  41. # 呼出对话框用Skin设定
  42.   FUKI_SKIN_NAME = "Window"
  43. # 字体大小
  44.   MES_FONT_SIZE = 20
  45. # 字体颜色
  46.   FUKI_COLOR = Color.new(100, 100, 0, 255)
  47. # 窗口透明度
  48.   FUKI_OPACITY = 200         # 呼出对话框
  49.   MES_OPACITY = 160          # 默认信息窗口
  50. # 窗口表示时是否根据画面大小自动检查窗口出现的位置,
  51. # 自动改变位置( true / false )
  52.   POS_FIX = true
  53. # 角色高度尺寸
  54.   CHARACTOR_HEIGHT = 50
  55. # 呼出对话框的相对位置(纵坐标)
  56.   POP_SHIFT_TOP = 0          # 表示位置为上的时候
  57.   POP_SHIFT_UNDER = -4       # 表示位置为下的时候
  58. # 信息的表示速度(数字越小速度越快,0为瞬间表示)
  59. # 游戏中 可随时用数字代入 $mes_speed 来改变消息表示速度。
  60.   MES_SPEED = 1
  61.   
  62.   $play_voice = true
  63.   $mes_name = ""
  64.   $mes_id   = nil
  65. #==============================================================================

  66. #==============================================================================
  67. # 方便用户同时设置2个常用参数而使用的函数
  68. #==============================================================================
  69. def chat(id = nil,name = "")
  70.   $mes_id = id
  71.   $mes_name = name
  72. end

  73. #==============================================================================
  74. # □ Game_Temp
  75. #==============================================================================

  76. class Game_Temp
  77.   attr_accessor  :namebmp              #保存头像图片的Hash表
  78.   alias initialize_fuki initialize
  79.   def initialize
  80.     initialize_fuki
  81.     # 如果不想使用角色名字直接作为头像文件名
  82.     # 可在这里重新设定角色名字与文件名的对应关系
  83.     @namebmp ={"玩家"=>"维斯特"}
  84.   end
  85. end

  86. #==============================================================================
  87. # ■ Window_InputNumber
  88. #==============================================================================

  89. class Window_InputNumber < Window_Base
  90.   #--------------------------------------------------------------------------
  91.   # ● 初始化对像
  92.   #     digits_max : 位数
  93.   #--------------------------------------------------------------------------
  94.   def initialize(digits_max)
  95.     @digits_max = digits_max
  96.     @number = 0
  97.     # 从数字的幅度计算(假定与 0~9 等幅)光标的幅度
  98.     dummy_bitmap = Bitmap.new(MES_FONT_SIZE, MES_FONT_SIZE)
  99.     @cursor_width = dummy_bitmap.text_size("0").width + 8
  100.     dummy_bitmap.dispose
  101.     super(0, 0, @cursor_width * @digits_max + 32, 64)
  102.     self.contents = Bitmap.new(width - 32, height - 32)
  103.     self.contents.font.size = MES_FONT_SIZE
  104.     self.contents.font.color = FUKI_COLOR
  105.     self.z += 9999
  106.     self.opacity = 0
  107.     @index = 0
  108.     refresh
  109.     update_cursor_rect
  110.   end
  111.   #--------------------------------------------------------------------------
  112.   # ● 更新光标矩形
  113.   #--------------------------------------------------------------------------
  114.   def update_cursor_rect
  115.     self.cursor_rect.set(@index * @cursor_width-4, 0, @cursor_width, MES_FONT_SIZE + 4)
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # ● 刷新
  119.   #--------------------------------------------------------------------------
  120.   def refresh
  121.     self.contents.clear
  122.     s = sprintf("%0*d", @digits_max, @number)
  123.     for i in 0...@digits_max
  124.       self.contents.draw_text(i * @cursor_width, 0, 24, MES_FONT_SIZE + 4, s[i,1])
  125.     end
  126.   end
  127. end

  128. #==============================================================================
  129. # □ Window_Message
  130. #==============================================================================

  131. class Window_Message < Window_Selectable
  132.   
  133.   #--------------------------------------------------------------------------
  134.   # ● 初始化状态
  135.   #--------------------------------------------------------------------------
  136.   def initialize
  137.     super(80, 304, 480, 160)
  138.     self.contents = Bitmap.new(width - 32, height - 32)
  139.     self.contents.font.color = text_color(0)
  140.     self.visible = false
  141.     self.z = 9998
  142.     @fade_in = false
  143.     @fade_out = false
  144.     @contents_showing = false
  145.     @cursor_width = 0
  146.     self.active = false
  147.     self.index = -1
  148.     @w = 0
  149.     @h = 0
  150.     @wait = 0
  151.     @dx = 0
  152.     @dy = 0
  153.     $mes_speed = MES_SPEED
  154.     #------------------------
  155.     # ★ 特殊时期中断标志
  156.     #------------------------
  157.     @no_term_stop = false
  158.     @save_x = 0
  159.     @save_y = 0
  160.     @old_text_info = []
  161.     @show_right = false
  162.     @show_name  = false
  163.     @face_width = 0
  164.   end
  165.   #--------------------------------------------------------------------------
  166.   # ○ 决定窗口尺寸并生成窗口
  167.   #--------------------------------------------------------------------------
  168.   def refresh_create
  169.     unless @no_term_stop
  170.       @pic_skin.dispose if @pic_skin != nil
  171.       if $game_temp.message_text.include?(":")
  172.         if $game_temp.message_text.include?("@r")
  173.           @show_right = true
  174.           $game_temp.message_text.sub!(/\@r/, "")
  175.         end
  176.         @show_name = true
  177.         $game_temp.message_text = '\c[7]【' + $game_temp.message_text
  178.         $game_temp.message_text.sub!(/\:/, '\c[7]】\c[0]')
  179.       end
  180.       self.contents.clear
  181.       self.contents.font.color = normal_color
  182.       # 取得窗口尺寸
  183.       get_windowsize
  184.       w = @w + 40
  185.       h = @h * (self.contents.font.size + 4) + 30
  186.       h = 64 if h < 64
  187.       # 生成呼出窗口
  188.       set_fukidasi(self.x, self.y, w, h)
  189.       draw_msg_face
  190.       create_backbmp
  191.     end
  192.     # 初始化信息表示使用的变量
  193.     @dx = @save_x
  194.     @dx += @face_width unless @show_right
  195.     @dy = @save_y
  196.     @cursor_width = 0
  197.     @contents_drawing = true
  198.     #update
  199.     # 瞬间表示的情况下
  200.     if $mes_speed == 0
  201.       # 循环信息描绘处理
  202.       while $game_temp.message_text != ""
  203.         draw_massage
  204.       end
  205.       draw_opt_text
  206.       @contents_showing_end = true
  207.       @contents_drawing = false
  208.     else
  209.       # 一个一个描绘文字
  210.       refresh_drawtext
  211.     end
  212.   end
  213.   #--------------------------------------------------------------------------
  214.   # ○ 一个一个描绘文字
  215.   #--------------------------------------------------------------------------
  216.   def refresh_drawtext
  217.     if $game_temp.message_text != ""
  218.       if @wait > 0
  219.         @wait -= 1
  220.       elsif @wait == 0
  221.         # 描绘处理
  222.         draw_massage
  223.         @wait = $mes_speed
  224.       end
  225.     else
  226.       draw_opt_text
  227.       @contents_showing_end = true
  228.       @contents_drawing = false
  229.     end
  230.   end
  231.   #--------------------------------------------------------------------------
  232.   # ○ 取得窗口尺寸
  233.   #--------------------------------------------------------------------------
  234.   def get_windowsize
  235.     get_face_width($mes_name)
  236.     x = y = 0
  237.     @h = @w = 0
  238.     @cursor_width = 0
  239.     # 有选择项的话,处理字的缩进
  240.     if $game_temp.choice_start == 0
  241.       x = 16
  242.     end
  243.     # 有等待显示的文字的情况下
  244.     if $game_temp.message_text != nil
  245.     text = $game_temp.message_text.clone
  246.       # 限制文字处理
  247.       begin
  248.         last_text = text.clone
  249.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  250.       end until text == last_text
  251.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  252.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  253.       end
  254.       text.gsub!(/\\\\/)                 { "\x00" }
  255.       text.gsub!(/\\[Cc]\[([0-9]+)\]/)   { "\x01" }
  256.       text.gsub!(/\\[Gg]/)               { "\x02" }
  257.       text.gsub!(/\\[Ss]\[([0-9]+)\]/)   { "\x03" + $data_skills[$1.to_i].name }
  258.       text.gsub!(/\\[Ii]\[([0-9]+)\]/)   { "\x04" + $data_items[$1.to_i].name }
  259.       text.gsub!(/\\[Ww]\[([0-9]+)\]/)   { "\x05" + $data_weapons[$1.to_i].name }
  260.       text.gsub!(/\\[Aa]\[([0-9]+)\]/)   { "\x06" + $data_armors[$1.to_i].name }
  261.       text.gsub!(/\\[Rr]\[([0-9]+)\]/)   { "\x10" + $game_actors[$1.to_i].name }
  262.       # c 获取 1 个字 (如果不能取得文字就循环)
  263.       while ((c = text.slice!(/./m)) != nil)
  264.         if c == "\x00"
  265.           c = "\\"
  266.         end
  267.         if c == "\x01" or c == "\x02"
  268.           next
  269.         end
  270.         if c == "\x03" or c == "\x04" or c == "\x05" or c == "\x06" or c == "\x010"
  271.           c = "   "
  272.         end
  273.         if c == "\n"
  274.           # y 累加 1
  275.           y += 1
  276.           # 取得纵横尺寸
  277.           @h = y
  278.           @w = x > @w ? x : @w
  279.           if y >= $game_temp.choice_start
  280.             @w = x + MES_FONT_SIZE > @w ? x + MES_FONT_SIZE : @w
  281.           end
  282.           x = 0
  283.           x = MES_FONT_SIZE if y >= $game_temp.choice_start
  284.           # 下面的文字
  285.           next
  286.         end
  287.         # x 为要描绘文字的宽度加法运算
  288.         x += self.contents.text_size(c).width
  289.       end
  290.     end
  291.     # 输入数值的情况
  292.     if $game_temp.num_input_variable_id > 0
  293.       digits_max = $game_temp.num_input_digits_max
  294.       number = $game_variables[$game_temp.num_input_variable_id]
  295.       @h += 1
  296.       x = digits_max * self.contents.font.size + 16
  297.       @w = x > @w ? x : @w
  298.     end
  299.     @w += @face_width
  300.     @w = 96 if @w < 96
  301.   end
  302.   #--------------------------------------------------------------------------
  303.   # ○ 描绘信息处理
  304.   #--------------------------------------------------------------------------
  305.   def draw_massage
  306.     # 有等待显示的文字的情况下
  307.     if $game_temp.message_text != nil or @old_text_info != nil
  308.       text = $game_temp.message_text
  309.       #p text
  310.       # 限制文字处理
  311.       begin
  312.         last_text = text.clone
  313.         text.gsub!(/\\[Vv]\[([0-9]+)\]/) { $game_variables[$1.to_i] }
  314.       end until text == last_text
  315.       text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  316.         $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  317.       end
  318.       text.gsub!(/\\\\/)                 { "\x00" }
  319.       text.gsub!(/\\[Cc]\[([0-9]+)\]/)   { "\x01[#{$1}]" }
  320.       text.gsub!(/\\[Gg]/)               { "\x02" }
  321.       text.gsub!(/\\[Ss]\[([0-9]+)\]/)   { "\x03[#{$1}]" }
  322.       text.gsub!(/\\[Ii]\[([0-9]+)\]/)   { "\x04[#{$1}]" }
  323.       text.gsub!(/\\[Ww]\[([0-9]+)\]/)   { "\x05[#{$1}]" }
  324.       text.gsub!(/\\[Aa]\[([0-9]+)\]/)   { "\x06[#{$1}]" }
  325.       text.gsub!(/\\[Oo]\[([0-9]+)\]/)   { "\x07[#{$1}]" }
  326.       text.gsub!(/\\[Qq]/)               { "\x08" }
  327.       text.gsub!(/\\[Ff]\[([0-9]+)\]/)   { "\x09[#{$1}]" }
  328.       text.gsub!(/\\[Rr]\[([0-9]+)\]/)   { "\x10[#{$1}]" }
  329.       # c 获取 1 个字
  330.       c = text.slice!(/./m)
  331.       # 选择项的情况
  332.       if @dy >= $game_temp.choice_start
  333.         # 处理字的缩进
  334.         @dx = MES_FONT_SIZE
  335.         @dx += @face_width unless @show_right
  336.         @dx += MES_FONT_SIZE if @show_name
  337.         # 描绘文字
  338.         self.contents.draw_text(@dx, 24 * @dy, 24, 24, c)
  339.         # x 为要描绘文字宽度的加法运算
  340.         @dx += self.contents.text_size(c).width
  341.         # 循环
  342.         while ((c = text.slice!(/./m)) != "\n")
  343.           # 描绘文字
  344.           self.contents.draw_text(@dx, 24 * @dy, 24, 24, c)
  345.           # x 为要描绘文字宽度的加法运算
  346.           @dx += self.contents.text_size(c).width
  347.         end
  348.         if c == "\n"
  349.           # 更新光标宽度
  350.           @cursor_width = [@cursor_width, @dx - @face_width].max
  351.           # dy 累加 1
  352.           @dy += 1
  353.         end
  354.         return
  355.       end
  356.       case c
  357.       when "\x00"
  358.         c = "\\"            
  359.       when "\x01"                  
  360.         text.sub!(/\[([0-9]+)\]/, "")
  361.         color = $1.to_i
  362.         self.contents.font.color = text_color(color)
  363.       when "\x02"
  364.         @contents_showing_end = true
  365.         @contents_drawing = false
  366.         terminate_messageX
  367.         @save_x = @dx
  368.         @save_y = @dy
  369.       when "\x03"
  370.         text.sub!(/\[([0-9]+)\]/, "")
  371.         last_character
  372.         draw_icon($data_skills[$1.to_i], 4 + @dx, 24 * @dy)
  373.         @dx += self.contents.text_size("   ").width
  374.       when "\x04"
  375.         text.sub!(/\[([0-9]+)\]/, "")
  376.         last_character
  377.         draw_icon($data_items[$1.to_i], 4 + @dx, 24 * @dy)
  378.         @dx += self.contents.text_size("   ").width
  379.       when "\x05"
  380.         text.sub!(/\[([0-9]+)\]/, "")
  381.         last_character
  382.         draw_icon($data_weapons[$1.to_i], 4 + @dx, 24 * @dy)
  383.         @dx += self.contents.text_size("   ").width
  384.       when "\x06"
  385.         text.sub!(/\[([0-9]+)\]/, "")
  386.         last_character
  387.         draw_icon($data_armors[$1.to_i], 4 + @dx, 24 * @dy)
  388.         @dx += self.contents.text_size("   ").width
  389.       when "\x07"
  390.         text.sub!(/\[([0-9]+)\]/, "")
  391.         self.contents.font.color.alpha = $1.to_i
  392.       when "\x08"
  393.         text.sub!(/\[([0-9]+)\]/, "")
  394.         $play_voice = !$play_voice
  395.       when "\x09"
  396.         text.sub!(/\[([0-9]+)\]/, "")
  397.         self.contents.font.name = FONT_ARRAY[$1.to_i]
  398.       when "\x10"
  399.         text.sub!(/\[([0-9]+)\]/, "")
  400.         last_character
  401.         draw_actor_graphic($game_actors[$1.to_i], 4 + @dx, 24 * @dy)
  402.         @dx += self.contents.text_size("   ").width
  403.       when "\n"
  404.         @dy += 1
  405.         @dx = 0
  406.         @dx += @face_width unless @show_right
  407.         @dx += MES_FONT_SIZE if @show_name
  408.         last_character
  409.       else
  410.         last_character
  411.         size_zy = 6  # 设定文字动态增大幅度
  412.         if c != nil
  413.           self.contents.font.size = MES_FONT_SIZE
  414.           font_size = self.contents.font.size += size_zy
  415.           @old_text_info.push(@dx , @dy , font_size, self.contents.font.color.clone, c)
  416.           self.contents.draw_text(4 + @dx, (font_size + 4 - size_zy) * @dy - size_zy / 2, font_size, font_size, c)
  417.           self.contents.font.size -= size_zy
  418.           Audio.se_play("Audio/SE/Voice", 90, 100) if $play_voice and c != " "
  419.           @dx += self.contents.text_size(c).width
  420.         end
  421.       end
  422.     end
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # ○ 完成上一个字符的描绘
  426.   #--------------------------------------------------------------------------
  427.   def last_character
  428.     size_zy = 6  # 设定文字动态增大幅度
  429.     unless @old_text_info == []
  430.       self.contents.fill_rect (4 + @old_text_info[0], (@old_text_info[2]+ 4 - size_zy) * @old_text_info[1] - size_zy / 2, @old_text_info[2], @old_text_info[2], Color.new(0,0,0,0))
  431.       color = self.contents.font.color.clone
  432.       self.contents.font.color = @old_text_info[3].clone
  433.       self.contents.font.size = @old_text_info[2] -= size_zy
  434.       self.contents.draw_text(4 + @old_text_info[0], (@old_text_info[2] + 4) * @old_text_info[1], @old_text_info[2], @old_text_info[2], @old_text_info[4])
  435.       self.contents.font.color = color
  436.       @old_text_info = []
  437.     end
  438.   end
  439.   #--------------------------------------------------------------------------
  440.   # ○ 选择项和输入数值的情况下
  441.   #--------------------------------------------------------------------------
  442.   def draw_opt_text
  443.     # 选择项的情况下
  444.     if $game_temp.choice_max > 0
  445.       @item_max = $game_temp.choice_max
  446.       self.active = true
  447.       self.index = 0
  448.     end
  449.     # 输入数值的情况下
  450.     if $game_temp.num_input_variable_id > 0
  451.       digits_max = $game_temp.num_input_digits_max
  452.       number = $game_variables[$game_temp.num_input_variable_id]
  453.       @input_number_window = Window_InputNumber.new(digits_max)
  454.       @input_number_window.number = number
  455.       @input_number_window.x = self.x + @face_width + MES_FONT_SIZE + 8
  456.       @input_number_window.y = self.y + $game_temp.num_input_start * (MES_FONT_SIZE + 2)
  457.     end
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # ○ 生成背景图片
  461.   #--------------------------------------------------------------------------
  462.   def create_backbmp
  463.     @pic_skin.dispose if @pic_skin != nil
  464.     @pic_skin = Sprite.new
  465.     @pic_skin.opacity = 0 unless @no_term_stop
  466.     @pic_skin.bitmap = Bitmap.new(self.width + 32, self.height + 32)
  467.     @pic_skin.x = self.x + 2
  468.     @pic_skin.y = self.y + 2
  469.     @pic_skin.z = self.z
  470.     bitmap = RPG::Cache.windowskin(FUKI_SKIN_NAME)
  471.     rect = Rect.new(0, 0, 32, 32)
  472.     @pic_skin.bitmap.blt(0, 0, bitmap, rect)
  473.     rect = Rect.new(96, 0, 32, 32)
  474.     @pic_skin.bitmap.blt(self.width-32, 0, bitmap, rect)
  475.     rect = Rect.new(0, 96, 32, 32)
  476.     @pic_skin.bitmap.blt(0, self.height-32, bitmap, rect)
  477.     rect = Rect.new(96, 96, 32, 32)
  478.     @pic_skin.bitmap.blt(self.width-32, self.height-32, bitmap, rect)
  479.     rect = Rect.new(0, 32, 32, 32)
  480.     @pic_skin.bitmap.stretch_blt(Rect.new(0, 32, 32, self.height - 64), bitmap, rect)
  481.     rect = Rect.new(96, 32, 32, 32)
  482.     @pic_skin.bitmap.stretch_blt(Rect.new(self.width-32,32,32,self.height-64), bitmap, rect)
  483.     rect = Rect.new(32, 0, 32, 32)
  484.     @pic_skin.bitmap.stretch_blt(Rect.new(32,0,self.width-64,self.height-32), bitmap, rect)
  485.     rect = Rect.new(32, 96, 32, 32)
  486.     @pic_skin.bitmap.stretch_blt(Rect.new(32,self.height-32,self.width-64,32), bitmap, rect)
  487.     bitmap.dispose
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # ○ 设置呼出对话框
  491.   #--------------------------------------------------------------------------
  492.   def set_fukidasi(x, y, width, height)
  493.     begin
  494.       self.pause = false # 不显示暂停标志
  495.       pos = get_fuki_pos(width, height) # 取得对话框位置
  496.       x = pos[0]
  497.       y = pos[1]
  498.       self.windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
  499.       self.x = x
  500.       self.y = y
  501.       self.height = height
  502.       self.width = width
  503.       unless @no_term_stop
  504.         self.contents.dispose
  505.         self.contents = Bitmap.new(width - 32, height - 32)
  506.         self.back_opacity = FUKI_OPACITY
  507.         self.contents.clear
  508.         self.contents.font.color = Color.new(0, 100, 0, 255)
  509.         self.contents.font.size = MES_FONT_SIZE
  510.       end
  511.       if $game_system.message_frame == 0
  512.         tale_pos = get_tale_pos
  513.         @tale = Sprite.new
  514.         @tale.bitmap = Bitmap.new(64, 32)
  515.         if TAIL_SHOW
  516.           case @message_position
  517.           when 0  # 上
  518.             bitmap = RPG::Cache.windowskin(FUKI_SKIN_NAME)
  519.             rect = Rect.new(32, 32, 64, 32)
  520.             @tale.bitmap.blt(0, 0, bitmap, rect)
  521.             bitmap.dispose
  522.             @tale.x = tale_pos[0]
  523.             @tale.x += 8 if @tale.x < 64
  524.             if @tale.x > 640 - 64
  525.               @tale.mirror = true
  526.               @tale.x -= 64
  527.             end
  528.             @tale.y = tale_pos[1]
  529.             @tale.z = self.z + 1
  530.           when 1  # 中
  531.             @tale.dispose
  532.             @tale = nil
  533.           when 2  # 下
  534.             bitmap = RPG::Cache.windowskin(FUKI_SKIN_NAME)
  535.             rect = Rect.new(32, 64, 64, 32)
  536.             @tale.bitmap.blt(0, 0, bitmap, rect)
  537.             bitmap.dispose
  538.             @tale.x = tale_pos[0]
  539.             @tale.x += 8 if @tale.x < 64
  540.             if @tale.x > 640 - 64
  541.               @tale.mirror = true
  542.               @tale.x -= 64
  543.             end
  544.             @tale.y = tale_pos[1]
  545.             @tale.z = self.z + 1
  546.           end
  547.         end
  548.       end
  549.     rescue
  550.       del_fukidasi
  551.       reset_window(width, height)
  552.     end
  553.   end
  554.   #--------------------------------------------------------------------------
  555.   # ○ 计算呼出对话框的位置
  556.   #--------------------------------------------------------------------------
  557.   def get_fuki_pos(width, height)
  558.     # 取得角色
  559.     @character = get_character($mes_id)
  560.     if @character == nil
  561.       # 角色不存在的情况下使用默认信息框
  562.       del_fukidasi
  563.       reset_window(width, height)
  564.       return
  565.     end
  566.     # 处理坐标
  567.     x = (@character.real_x - $game_map.display_x + 64) * 32 / 128 - (width / 2)
  568.     # 为尽量显示在画面内而移动横坐标
  569.     if x + width > 640
  570.       x = 640 - width
  571.     elsif x < 0
  572.       x = 0
  573.     end
  574.     # 决定窗口位置
  575.     case $game_system.message_position
  576.     when 0  # 上
  577.       y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - CHARACTOR_HEIGHT + POP_SHIFT_TOP
  578.     when 1  # 中
  579.       x = (640 - width) / 2
  580.       y = (480 - height) / 2
  581.     when 2  # 下
  582.       y =  (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + POP_SHIFT_UNDER
  583.     end
  584.     # 纪录文章显示位置
  585.     @message_position = $game_system.message_position
  586.     if POS_FIX
  587.       case @message_position
  588.       when 0  # 上
  589.         if y <= 0
  590.           @message_position = 2
  591.           y =  (@character.real_y - $game_map.display_y + 64) * 32 / 128 + 32 + POP_SHIFT_UNDER
  592.         end
  593.       when 2  # 下
  594.         if y + height >= 480
  595.           @message_position = 0
  596.           y = (@character.real_y - $game_map.display_y + 64) * 32 / 128 - height - CHARACTOR_HEIGHT + POP_SHIFT_TOP
  597.         end
  598.       end
  599.     end
  600.     return [x, y]
  601.   end
  602.   #--------------------------------------------------------------------------
  603.   # ○ 计算尾部图标的位置
  604.   #--------------------------------------------------------------------------
  605.   def get_tale_pos
  606.     case @message_position
  607.     when 0  # 上
  608.       # 处理坐标
  609.       x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 8
  610.       y = self.y + self.height - 6
  611.     when 1  # 中
  612.       x = nil
  613.       y = nil
  614.     when 2  # 下
  615.       # 处理坐标
  616.       x = ( @character.real_x - $game_map.display_x + 64 ) * 32 / 128 - 8
  617.       y = self.y - 18
  618.     end
  619.     return [x, y]
  620.   end
  621.   #--------------------------------------------------------------------------
  622.   # ○ 设置角色半身像窗口
  623.   #--------------------------------------------------------------------------
  624.   def draw_msg_face
  625.     @face_sprite.dispose if @face_sprite != nil
  626.     # $mes_name为空时不显示
  627.     if $mes_name == nil or $mes_name == ""
  628.       return
  629.     else
  630.       # 设定变量
  631.       mes_name = $mes_name
  632.       if $game_temp.namebmp[mes_name] == nil
  633.         sFile = FACE_PIC_DIR + mes_name
  634.       else
  635.         sFile = FACE_PIC_DIR + $game_temp.namebmp[mes_name]
  636.       end
  637.       bitmap = Bitmap.new(sFile)
  638.       @pic_width = bitmap.width
  639.       @pic_height = bitmap.height
  640.       @face_sprite = Sprite.new
  641.       @face_sprite.x = self.x + 26
  642.       @face_sprite.x = self.x + self.width - @pic_width - 26 if @show_right
  643.       @face_sprite.y = self.y + self.height - @pic_height - 6
  644.       @face_sprite.bitmap = bitmap
  645.       @face_sprite.z = self.z + 3
  646.       @face_sprite.mirror = @show_right
  647.       @face_sprite.opacity = 0
  648.     end
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # ○ 释放呼出对话框
  652.   #--------------------------------------------------------------------------
  653.   def del_fukidasi
  654.     if @tale != nil
  655.       @tale.dispose
  656.       @tale = nil
  657.     end
  658.     self.opacity = 0
  659.     self.x = 80
  660.     self.width = 480
  661.     self.height = 160
  662.     self.contents.dispose
  663.     self.contents = Bitmap.new(width - 32, height - 32)
  664.     self.pause = true
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # ○ 取得角色
  668.   #     parameter : 参数
  669.   #--------------------------------------------------------------------------
  670.   def get_character(parameter)
  671.     # 参数分歧
  672.     case parameter
  673.     when nil
  674.       return events == nil
  675.     when -1  # 玩家
  676.       return $game_player
  677.     when 0   # 该事件
  678.       events = $game_map.events
  679.       return events == nil ? nil : events[$active_event_id]
  680.     else     # 特定事件
  681.       events = $game_map.events
  682.       return events == nil ? nil : events[parameter]
  683.     end
  684.   end
  685.   #--------------------------------------------------------------------------
  686.   # ● 设定窗口位置和不透明度
  687.   #--------------------------------------------------------------------------
  688.   def reset_window(width = nil, height = nil)
  689.     if $game_temp.in_battle
  690.       self.y = 16
  691.     else
  692.       case $game_system.message_position
  693.       when 0  # 上
  694.         self.y = 16
  695.       when 1  # 中
  696.         if height != nil and width != nil
  697.           self.y = (480 - height) / 2 - 32
  698.           self.x = (640 - width) / 2
  699.           self.width = width
  700.           self.height = height
  701.           self.contents.dispose
  702.           self.contents = Bitmap.new(width - 32, height - 32)
  703.         else
  704.           self.y = 160
  705.         end
  706.       when 2  # 下
  707.         self.y = 304
  708.       end
  709.     end
  710.     self.opacity = 0
  711.     self.back_opacity = MES_OPACITY
  712.   end
  713.   #--------------------------------------------------------------------------
  714.   # ● 刷新画面
  715.   #--------------------------------------------------------------------------
  716.   def update
  717.     super
  718.     update_fuki                 # 呼出模式下跟随事件移动
  719.     if @fade_in                 # 渐变的情况下
  720.       self.contents_opacity += 24
  721.       @pic_skin.opacity += 20
  722.       if @tale != nil
  723.         @face_sprite.opacity += 24 if @face_sprite != nil and !@face_sprite.disposed?
  724.         @tale.opacity += 20
  725.       end
  726.       @input_number_window.contents_opacity += 24 if @input_number_window != nil
  727.       @fade_in = false if self.contents_opacity == 255
  728.       return
  729.     end
  730.     if @contents_drawing        # 显示信息中的情况下
  731.       refresh_drawtext
  732.       return
  733.     end
  734.     update_input_number_window  # 输入数值的情况下
  735.     if @contents_showing_end    # 显示信息结束的情况下
  736.       if $game_temp.choice_max == 0 and @tale == nil
  737.         self.pause = true
  738.       else
  739.         self.pause = false
  740.       end
  741.       update_choose
  742.       return
  743.     end
  744.     if @fade_out == false and $game_temp.message_text != nil # 在渐变以外的状态下
  745.       @contents_showing = true
  746.       $game_temp.message_window_showing = true
  747.       reset_window
  748.       refresh_create
  749.       if @no_term_stop
  750.         self.visible = true        
  751.       else
  752.         @tale.opacity = 0 if @tale != nil
  753.         Graphics.frame_reset
  754.         self.visible = true
  755.         self.contents_opacity = 0
  756.         @input_number_window.contents_opacity = 0 if @input_number_window != nil
  757.         @fade_in = true
  758.       end
  759.       return
  760.     end
  761.     unless @no_term_stop # 没有可以显示的信息、但是窗口为可见的情况下
  762.       if self.visible
  763.         @fade_out = true
  764.         self.opacity -= 48
  765.         @face_sprite.opacity -= 48 if @face_sprite != nil and !@face_sprite.disposed?
  766.         @pic_skin.opacity -= 48 if @pic_skin != nil and !@pic_skin.disposed?
  767.         @tale.opacity -= 48 if @tale != nil and [email protected]?
  768.         if (@face_sprite == nil) or @face_sprite.disposed? or (@face_sprite.opacity == 0)
  769.           self.visible = false
  770.           @face_sprite.dispose if @face_sprite != nil
  771.           @pic_skin.dispose
  772.           @fade_out = false
  773.           $game_temp.message_window_showing = false
  774.           del_fukidasi
  775.         end
  776.         return
  777.       end
  778.     else
  779.       $game_temp.message_window_showing = false   
  780.     end
  781.   end
  782.   #--------------------------------------------------------------------------
  783.   # ● 释放
  784.   #--------------------------------------------------------------------------
  785.   def dispose
  786.     terminate_message
  787.     $game_temp.message_window_showing = false
  788.     @input_number_window.dispose if @input_number_window != nil
  789.     super
  790.   end
  791.   #--------------------------------------------------------------------------
  792.   # ● 信息结束处理
  793.   #--------------------------------------------------------------------------
  794.   def terminate_message
  795.     self.active = false
  796.     self.pause = false
  797.     self.index = -1
  798.     self.contents.clear
  799.     # 清除显示中标志
  800.     @contents_showing = false
  801.     @contents_showing_end = false
  802.     $mes_name = ""
  803.     # 呼叫信息调用
  804.     $game_temp.message_proc.call if $game_temp.message_proc != nil
  805.     # 清除文章、选择项、输入数值的相关变量
  806.     $game_temp.message_text = nil
  807.     $game_temp.message_proc = nil
  808.     $game_temp.choice_start = 99
  809.     $game_temp.choice_max = 0
  810.     $game_temp.choice_cancel_type = 0
  811.     $game_temp.choice_proc = nil
  812.     $game_temp.num_input_start = 99
  813.     $game_temp.num_input_variable_id = 0
  814.     $game_temp.num_input_digits_max = 0
  815.     # 释放金钱窗口
  816.     if @gold_window != nil
  817.       @gold_window.dispose
  818.       @gold_window = nil
  819.     end
  820.     @no_term_stop = false
  821.     @save_x = 0
  822.     @save_y = 0
  823.     @show_right = false
  824.     @show_name  = false
  825.     @face_width = 0
  826.   end
  827.   #--------------------------------------------------------------------------
  828.   # ● ★信息结束处理★
  829.   #--------------------------------------------------------------------------
  830.   def terminate_messageX
  831.     self.active = false
  832.     self.pause = false
  833.     self.index = -1
  834.     # 清除显示中标志
  835.     @contents_showing = false
  836.     @contents_showing_end = false
  837.     # 呼叫信息调用
  838.     $game_temp.message_proc.call if $game_temp.message_proc != nil
  839.     # 清除文章、选择项、输入数值的相关变量
  840.     $game_temp.message_text = nil
  841.     $game_temp.message_proc = nil
  842.     @no_term_stop = true
  843.     @show_right = false
  844.     @show_name  = false
  845.     @face_width = 0
  846.   end
  847.   #--------------------------------------------------------------------------
  848.   # ● 刷新光标矩形
  849.   #--------------------------------------------------------------------------
  850.   def update_cursor_rect
  851.     if @index >= 0
  852.       n = $game_temp.choice_start + @index
  853.       self.cursor_rect.set(MES_FONT_SIZE / 2, n * (MES_FONT_SIZE + 4), @cursor_width, MES_FONT_SIZE + 4)
  854.       self.cursor_rect.x += @face_width unless @show_right
  855.       self.cursor_rect.x += MES_FONT_SIZE / 2 if @show_name
  856.     else
  857.       self.cursor_rect.empty
  858.     end
  859.   end
  860.   #--------------------------------------------------------------------------
  861.   # ● 获取文字颜色色
  862.   #     n : 文字颜色编号 (0~31)
  863.   #--------------------------------------------------------------------------
  864.   def text_color(n)
  865.     return normal_color if n > 31
  866.     x = (n % 8) * 16
  867.     y = 128 + (n / 8) * 16
  868.     return RPG::Cache.windowskin(FUKI_SKIN_NAME).get_pixel(x, y)
  869.   end
  870.   #--------------------------------------------------------------------------
  871.   # ● 取得普通文字色
  872.   #--------------------------------------------------------------------------
  873.   def normal_color
  874.     nil_color = Color.new(0,100,0,255)
  875.     return FUKI_COLOR if FUKI_COLOR != nil_color
  876.     return nil_color
  877.   end
  878.   #--------------------------------------------------------------------------
  879.   # ● 获取头像宽度
  880.   #--------------------------------------------------------------------------
  881.   def get_face_width(face_name)
  882.     return if $mes_name == ""
  883.     filename = FACE_PIC_DIR + face_name
  884.     bitmap = Bitmap.new(filename)
  885.     @face_width = bitmap.width + MES_FONT_SIZE
  886.     bitmap.dispose
  887.   end
  888.   #--------------------------------------------------------------------------
  889.   # ● 描绘物品
  890.   #     item : 物品
  891.   #--------------------------------------------------------------------------
  892.   def draw_icon(item, x, y)
  893.     return if item == nil
  894.     bitmap = RPG::Cache.icon(item.icon_name)
  895.     self.contents.blt(x + 4, y, bitmap, Rect.new(0, 0, 24, 24))
  896.     color = self.contents.font.color.clone
  897.     self.contents.font.color = text_color(1)
  898.     self.contents.draw_text(x + 28, y, self.contents.text_size(item.name).width + 5, 24, item.name)
  899.     self.contents.font.color = color
  900.     @dx += self.contents.text_size(item.name).width
  901.   end
  902.   #--------------------------------------------------------------------------
  903.   # ● 图形的描绘
  904.   #     actor : 角色
  905.   #     x     : 描画目标 X 坐标
  906.   #     y     : 描画目标 Y 坐标
  907.   #--------------------------------------------------------------------------
  908.   def draw_actor_graphic(actor, x, y)
  909.     bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
  910.     cw = bitmap.width / 4
  911.     ch = bitmap.height / 4
  912.     src_rect = Rect.new(0, 0, cw, ch)
  913.     self.contents.blt(x, y - 4, bitmap, src_rect)
  914.     color = self.contents.font.color.clone
  915.     self.contents.font.color = text_color(1)
  916.     self.contents.draw_text(x + 32, y, self.contents.text_size(actor.name).width + 5, 24, actor.name)
  917.     self.contents.font.color = color
  918.     @dx += self.contents.text_size(actor.name).width
  919.   end
  920.   #--------------------------------------------------------------------------
  921.   # ● 刷新呼出对话框
  922.   #--------------------------------------------------------------------------
  923.   def update_fuki
  924.     if @tale != nil
  925.       pos = get_fuki_pos(self.width, self.height)
  926.       self.x = pos[0]
  927.       self.y = pos[1]
  928.       tale_pos = get_tale_pos
  929.       @tale.mirror = false
  930.       @tale.x = tale_pos[0]
  931.       @tale.x += 8 if @tale.x < 64
  932.       if @tale.x > 640 - 64
  933.         @tale.mirror = true
  934.         @tale.x -= 64
  935.       end
  936.       @tale.y = tale_pos[1]
  937.       @pic_skin.x = self.x + 2
  938.       @pic_skin.y = self.y + 2
  939.       if @face_sprite != nil and !@face_sprite.disposed?
  940.         @face_sprite.x = self.x + 26
  941.         @face_sprite.x = self.x + self.width - @pic_width - 26 if @show_right
  942.         @face_sprite.y = self.y + self.height - @pic_height - 6
  943.       end
  944.     end
  945.   end
  946.   #--------------------------------------------------------------------------
  947.   # ● 刷新数字输入框
  948.   #--------------------------------------------------------------------------
  949.   def update_input_number_window
  950.     if @input_number_window != nil
  951.       @input_number_window.update
  952.       # 确定
  953.       if Input.trigger?(Input::C)
  954.         $game_system.se_play($data_system.decision_se)
  955.         $game_variables[$game_temp.num_input_variable_id] = @input_number_window.number
  956.         # 释放输入数值窗口
  957.         @input_number_window.dispose
  958.         @input_number_window = nil
  959.         $game_map.need_refresh = true
  960.         terminate_message
  961.         del_fukidasi
  962.       end
  963.       return
  964.     end
  965.   end
  966.   #--------------------------------------------------------------------------
  967.   # ● 刷新选择输入
  968.   #--------------------------------------------------------------------------
  969.   def update_choose
  970.     if Input.trigger?(Input::B)
  971.       if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  972.         $game_system.se_play($data_system.cancel_se)
  973.         $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  974.         terminate_message
  975.         del_fukidasi
  976.       end
  977.     end
  978.     if Input.trigger?(Input::C)
  979.       if $game_temp.choice_max > 0
  980.         $game_system.se_play($data_system.decision_se)
  981.         $game_temp.choice_proc.call(self.index)
  982.       end
  983.       terminate_message
  984.       del_fukidasi
  985.     end
  986.   end
  987. end
复制代码
事件内容:
脚本:$mes_id = 1  #对话框出现在1号事件头顶
         $mes_name = " "  #引号里输入你的图片名字
文章:你好啊。我是XXX   

这样就行了。另外  文章:@or 你好啊。我是XXX  #加上@or 图片显示在右边  

点评

能详说吗?加Q873058488  发表于 2012-8-1 15:50
回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3065
在线时间
1429 小时
注册时间
2009-7-27
帖子
1448
3
发表于 2012-8-1 14:39:20 | 只看该作者
显示图片,对话,再取消图片即可

博客:我的博客
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
32 小时
注册时间
2012-7-28
帖子
63
4
 楼主| 发表于 2012-8-1 15:47:11 | 只看该作者
爆焰 发表于 2012-8-1 14:39
显示图片,对话,再取消图片即可

······加我q,详说吧,我没弄明白,本人纯新手


‘‘──心倾河中于2012-8-1 15:48补充以下内容:

······加我q,详说吧,我没弄明白,本人纯新手
’’

点评

好啊,你Q是多少呀?  发表于 2012-8-1 15:51
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
85 小时
注册时间
2012-4-25
帖子
192
5
发表于 2012-8-1 17:52:32 | 只看该作者
这。。。你不是QQ说吧最佳给我么。我了个去  

简直是坑爹啊~~~~~~~~

点评

对不起额,点错了·······  发表于 2012-8-2 14:46
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 18:55

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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