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

Project1

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

[已经解决] windows_message2对话系统脚本头像叠加的问题

[复制链接]

Lv4.逐梦者

梦石
8
星屑
4801
在线时间
1567 小时
注册时间
2014-1-9
帖子
402

开拓者

跳转到指定楼层
1
发表于 2016-10-2 22:29:45 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 余音·魔眼 于 2016-10-2 22:38 编辑

用了此脚本后突然发现 求解决下面是脚本:
windows_message2


#encoding:utf-8
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  显示文字信息的窗口。
#==============================================================================

class Window_Message < Window_Base
   #attr_reader   :firstCode
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  #    bitmap = Cache.system("Iconset")
  #    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
  #    contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  def initialize
    super(0, 0, window_width, window_height)
    @fukiId = -1;
    @down = false
    init_fuki_sharp
    self.z = 200
    self.openness = 0
    create_all_windows
    create_back_bitmap
    create_back_sprite
    clear_instance_variables

  end

  #--------------------------------------------------------------------------
  # ● 输出一个字符后的等待
  #--------------------------------------------------------------------------
  def wait_for_one_character
    wait(1)
    update_show_fast
    Fiber.yield unless @show_fast || @line_show_fast
  end

def init_fuki_sharp
    @fuki_sharp_up = Sprite.new
    @fuki_sharp_down = Sprite.new
    @fuki_sharp_up.bitmap = Cache.system("sharp_up")
    @fuki_sharp_down.bitmap = Cache.system("sharp_down")
    @fuki_sharp_up.visible = false
    @fuki_sharp_down.visible = false
    @fuki_sharp_up.ox = @fuki_sharp_up.bitmap.width - 2
    @fuki_sharp_up.oy = @fuki_sharp_up.bitmap.height
    @fuki_sharp_down.ox = 2
    @fuki_sharp_down.oy = 0
    @fuki_sharp_up.z = 300
    @fuki_sharp_down.z = 300
end

def dispose_sharp
    @fuki_sharp_up.bitmap.dispose
    @fuki_sharp_down.bitmap.dispose
    @fuki_sharp_up.dispose
    @fuki_sharp_down.dispose
end

def close_sharp
    @fuki_sharp_up.visible = false
    @fuki_sharp_down.visible = false

end

  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    if @fukiId == -1
        return Graphics.width
    else
        if @background == 1
          return Graphics.width
        else
          return Graphics.width*2/3
        end
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的高度
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(visible_line_number)
  end
  #--------------------------------------------------------------------------
  # ● 清除实例变量
  #--------------------------------------------------------------------------
  def clear_instance_variables
    @fiber = nil                # 纤程
    @background = 0             # 背景类型
    @position = 2               # 显示位置
    clear_flags
  end
  #--------------------------------------------------------------------------
  # ● 清除的标志
  #--------------------------------------------------------------------------
  def clear_flags
    @show_fast = false          # 快进的标志
    @line_show_fast = false     # 行单位快进的标志
    @pause_skip = false         # “不等待输入”的标志
  end
  #--------------------------------------------------------------------------
  # ● 获取显示行数
  #--------------------------------------------------------------------------
  def visible_line_number
    return 4
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    super
    dispose_all_windows
    dispose_back_bitmap
    dispose_back_sprite
    dispose_sharp
    @face_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    super
    update_all_windows
    update_back_sprite
    update_fiber
    if @fukiId > -1
        update_placement
    end
  end
  #--------------------------------------------------------------------------
  # ● 更新纤程
  #--------------------------------------------------------------------------
  def update_fiber
    if @fiber
      @fiber.resume
    elsif $game_message.busy? && !$game_message.scroll_mode
      @fiber = Fiber.new { fiber_main }
      @fiber.resume
    else
      $game_message.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # ● 生成所有窗口
  #--------------------------------------------------------------------------
  def create_all_windows
    @gold_window = Window_Gold.new
    @gold_window.x = Graphics.width - @gold_window.width
    @gold_window.y = 0
    @gold_window.openness = 0
    @choice_window = Window_ChoiceList.new(self)
    @number_window = Window_NumberInput.new(self)
    @item_window = Window_KeyItem.new(self)
    @face_window = Window_Face.new
  end
  #--------------------------------------------------------------------------
  # ● 生成背景位图
  #--------------------------------------------------------------------------
  def create_back_bitmap
    @back_bitmap = Bitmap.new(Graphics.width, height)
    rect1 = Rect.new(0, 0, Graphics.width, 12)
    rect2 = Rect.new(0, 12, Graphics.width, height - 24)
    rect3 = Rect.new(0, height - 12, Graphics.width, 12)
    @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(rect2, back_color1)
    @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
  end

  def update_back_bitmap
    rect1 = Rect.new(0, 0, Graphics.width, 12)
    rect2 = Rect.new(0, 12, Graphics.width, height - 24)
    rect3 = Rect.new(0, height - 12, Graphics.width, 12)
    rect4 = Rect.new(0,height,Graphics.width,@back_bitmap.height-height);
    @back_bitmap.gradient_fill_rect(rect1, back_color2, back_color1, true)
    @back_bitmap.fill_rect(rect2, back_color1)
    @back_bitmap.gradient_fill_rect(rect3, back_color1, back_color2, true)
    @back_bitmap.fill_rect(rect4, back_color2)
  end

  #--------------------------------------------------------------------------
  # ● 获取背景色 1
  #--------------------------------------------------------------------------
  def back_color1
    Color.new(0, 0, 0, 160)
  end
  #--------------------------------------------------------------------------
  # ● 获取背景色 2
  #--------------------------------------------------------------------------
  def back_color2
    Color.new(0, 0, 0, 0)
  end
  #--------------------------------------------------------------------------
  # ● 生成背景精灵
  #--------------------------------------------------------------------------
  def create_back_sprite
    @back_sprite = Sprite.new
    @back_sprite.bitmap = @back_bitmap
    @back_sprite.visible = false
    @back_sprite.z = z - 1
  end
  #--------------------------------------------------------------------------
  # ● 释放所有窗口
  #--------------------------------------------------------------------------
  def dispose_all_windows
    @gold_window.dispose
    @choice_window.dispose
    @number_window.dispose
    @item_window.dispose
  end
  #--------------------------------------------------------------------------
  # ● 释放背景位图
  #--------------------------------------------------------------------------
  def dispose_back_bitmap
    @back_bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # ● 释放背景精灵
  #--------------------------------------------------------------------------
  def dispose_back_sprite
    @back_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # ● 更新所有窗口
  #--------------------------------------------------------------------------
  def update_all_windows
    @gold_window.update
    @choice_window.update
    @number_window.update
    @item_window.update
    @face_window.update
  end
  #--------------------------------------------------------------------------
  # ● 更新背景精灵
  #--------------------------------------------------------------------------
  def update_back_sprite
    @back_sprite.visible = (@background == 1)
    @back_sprite.y = y
    @back_sprite.opacity = openness
    @back_sprite.update
  end

  #--------------------------------------------------------------------------
  # ● 处理纤程的主逻辑
  #--------------------------------------------------------------------------
  def fiber_main
    $game_message.visible = true
    update_background
    update_placement
    loop do
      process_all_text if $game_message.has_text?
      process_input
      $game_message.clear
      @gold_window.close
      Fiber.yield
      break unless text_continue?
    end
    close_and_wait
    $game_message.visible = false
    @fiber = nil
  end
  #--------------------------------------------------------------------------
  # ● 更新窗口背景
  #--------------------------------------------------------------------------
  def update_background
    @background = $game_message.background
    self.opacity = @background == 0 ? 255 : 0
  end
  #--------------------------------------------------------------------------
  # ● 更新窗口的位置
  #--------------------------------------------------------------------------
  def update_placement
    down_tmp = false
    idx = 0
    idy = 0
    if @fukiId == 0
        idy = $game_map.adjust_y($game_player.real_y)*32
        idx = $game_map.adjust_x($game_player.real_x)*32 + 16
    elsif @fukiId > 0
        idy = $game_map.adjust_y($game_map.events[@fukiId].real_y)*32
        idx = $game_map.adjust_x($game_map.events[@fukiId].real_x)*32 + 16
    else
      self.y = @position * (Graphics.height - height) / 2
      self.x = 0
    end

    #puts @face_window.visible,self.visible

    if @background == 1
      idx = Graphics.width/2
      idy = @position*(Graphics.height - 100)/2 + 50 + height
    end

    tmp_y =  idy - self.height - 23
    tmp_x =  idx - self.width/2

    face_window_x = update_face_window_x(tmp_x)
    face_window_y = update_face_window_y(tmp_y,down_tmp)

    if tmp_y < 0 || (@face_window.visible && face_window_y < 0)
        @down = true
        down_tmp = true
        tmp_y = idy + 32 + 23
    end

    if tmp_x < 0 || (@face_window.visible && face_window_x < 0)
        tmp_x = @face_window.visible ? @face_window.width : 0
    end

    if tmp_x + self.width > Graphics.width
        tmp_x = Graphics.width - self.width
    end

    if @fukiId > -1
      self.x = tmp_x
      self.y = tmp_y      
      @face_window.update_placement(self.x,self.y,self.height,@down)
      if down_tmp
          @fuki_sharp_down.x = idx
          @fuki_sharp_down.y = idy + 32 + 10
          @fuki_sharp_down.visible = @background == 0 ? true : false
          @fuki_sharp_up.visible = false
      else
          @fuki_sharp_up.x = idx
          @fuki_sharp_up.y = idy - 10
          @fuki_sharp_up.visible = @background == 0 ? true : false
          @fuki_sharp_down.visible = false
      end
    end


    @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
  end

  def update_face_window_x(tmp_x)
    return tmp_x - @face_window.width
  end

  def update_face_window_y(tmp_y,down)
    if !down
      return tmp_y + self.height - @face_window.height
    else
      return tmp_y
    end
  end

  #--------------------------------------------------------------------------
  # ● 处理所有内容
  #--------------------------------------------------------------------------
  def process_all_text
    @fukiId = -1;
    @down = false;
    text = convert_escape_characters($game_message.all_text)
    if text[0] == "u"
        text.slice!(0,1);
        @fukiId = obtain_escape_param(text)
    end
    @background = $game_message.background
    self.width = window_width
    pos = {}
    new_page(text, pos)
    open_and_wait

    text_tmp = text
    process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
  #--------------------------------------------------------------------------
  # ● 输入处理
  #--------------------------------------------------------------------------
  def process_input
    if $game_message.choice?
      input_choice
    elsif $game_message.num_input?
      input_number
    elsif $game_message.item_choice?
      input_item
    else
      input_pause unless @pause_skip
    end
  end
  #--------------------------------------------------------------------------
  # ● 打开窗口并等待窗口开启完成
  #--------------------------------------------------------------------------
  def open_and_wait
    open
    @face_window.open
    Fiber.yield until ( open? && @face_window.open? )
  end
  #--------------------------------------------------------------------------
  # ● 关闭窗口并等待窗口关闭完成
  #--------------------------------------------------------------------------
  def close_and_wait
    close
    @face_window.close
    @fukiId = -1
    close_sharp
    Fiber.yield until all_close?
  end
  #--------------------------------------------------------------------------
  # ● 判定是否所有窗口已全部关闭
  #--------------------------------------------------------------------------
  def all_close?
    close? && @choice_window.close? &&
    @number_window.close? && @item_window.close? && @face_window.close?
  end
  #--------------------------------------------------------------------------
  # ● 判定文字是否继续显示
  #--------------------------------------------------------------------------
  def text_continue?
    $game_message.has_text? && !settings_changed?
  end
  #--------------------------------------------------------------------------
  # ● 判定背景和位置是否被更改
  #--------------------------------------------------------------------------
  def settings_changed?
    @background != $game_message.background ||
    @position != $game_message.position
  end
  #--------------------------------------------------------------------------
  # ● 等待
  #--------------------------------------------------------------------------
  def wait(duration)
    duration.times { Fiber.yield }
  end
  #--------------------------------------------------------------------------
  # ● 监听“确定”键的按下,更新快进的标志
  #--------------------------------------------------------------------------
  def update_show_fast
    @show_fast = true if Input.trigger?(:C)
  end

  #--------------------------------------------------------------------------
  # ● 翻页处理
  #--------------------------------------------------------------------------
  def new_page(text, pos)
    @down = false
    @fuki_sharp_down.visible = false
    @fuki_sharp_up.visible = false
    @line_num = 0
    @max_width = 0
    @position = $game_message.position
    text_tmp = text.rstrip
    if @fukiId > -1
      calc_width(text_tmp)
      self.width = @max_width + standard_padding*2
      self.height = fitting_height(@line_num + 1 > 4 ? 4 : @line_num + 1)
    else
      self.width = Graphics.width
      self.height = fitting_height(4)
      update_placement
    end
    update_back_bitmap
    contents.dispose
    create_contents
    contents.clear

    @face_window.visible = @face_window.need_show(@fukiId)
    draw_face
    reset_font_settings
    pos[:x] = new_line_x
    pos[:y] = 0
    pos[:new_x] = new_line_x
    pos[:height] = calc_line_height(text)
    clear_flags
  end
  #--------------------------------------------------------------------------
  # ● 获取换行位置
  #--------------------------------------------------------------------------
  def new_line_x
    if @fukiId == -1
      $game_message.face_name.empty? ? 0 : 112
    else
      0
    end
  end


  def draw_face
    if @fukiId == -1
      super($game_message.face_name, $game_message.face_index, 0, 0)
    else
      @face_window.draw_face
    end
  end

  #--------------------------------------------------------------------------
  # ● 文字的处理
  #     c    : 文字
  #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  #--------------------------------------------------------------------------
  def process_character(c, text, pos)
    case c
    when "\r"   # 回车
      return
    when "\n"   # 换行
      process_new_line(text, pos)
    when "\f"   # 翻页
      process_new_page(text, pos)
    when "\e"   # 控制符
      process_escape_character(obtain_escape_code(text), text, pos)
    else        # 普通文字
      process_normal_character(c, pos,text)
    end
  end

  #计算宽度
  def calc_width(text)
    lines = Array.new(10,0)
    calc_c_width(text.slice!(0, 1), text,lines) until text.empty?
    @max_width = @max_width < lines[@line_num] ? lines[@line_num] : @max_width
  end

  def calc_new_line(lines)
    @max_width = @max_width < lines[@line_num] ? lines[@line_num] : @max_width
    @line_num += 1
  end

  def calc_c_width(c, text,lines)
    case c
    when "\r"
    when "\n"
        calc_new_line(lines)
    when "\f"
    when "\e"
        obtain_escape_code(text)
        obtain_escape_param(text)
    else
        calc_normal_c(c,lines)
    end
  end

  def calc_normal_c(c,lines)
    text_width = text_size(c).width
    if lines[@line_num] + text_width > window_width - standard_padding*2
        @max_width = lines[@line_num]
        @line_num += 1
    end
    lines[@line_num] += text_size(c).width
  end

    # 处理普通文本

  def process_normal_character(c, pos, text)
    text_width = text_size(c).width
    if pos[:x] + text_width > contents_width
        process_new_line(text,pos)
    end
    draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
    pos[:x] += text_width
    wait_for_one_character
  end

  #--------------------------------------------------------------------------
  # ● 普通文字的处理
  #--------------------------------------------------------------------------
  #def process_normal_character(c, pos)
  #  super
  #  wait_for_one_character
  #end
  #--------------------------------------------------------------------------
  # ● 换行文字的处理
  #--------------------------------------------------------------------------
  def process_new_line(text, pos)
    @line_show_fast = false
    super
    if need_new_page?(text, pos)
      input_pause
      new_page(text, pos)
    end
  end
  #--------------------------------------------------------------------------
  # ● 判定是否需要翻页
  #--------------------------------------------------------------------------
  def need_new_page?(text, pos)
    pos[:y] + pos[:height] > contents.height && !text.empty?
  end
  #--------------------------------------------------------------------------
  # ● 翻页文字的处理
  #--------------------------------------------------------------------------
  def process_new_page(text, pos)
    text.slice!(/^\n/)
    input_pause
    new_page(text, pos)
  end
  #--------------------------------------------------------------------------
  # ● 处理控制符指定的图标绘制
  #--------------------------------------------------------------------------
  def process_draw_icon(icon_index, pos)
    super
    wait_for_one_character
  end


  #--------------------------------------------------------------------------
  # ● 控制符的处理
  #     code : 控制符的实际形式(比如“\C[1]”是“C”)
  #     text : 绘制处理中的字符串缓存(字符串可能会被修改)
  #     pos  : 绘制位置 {:x, :y, :new_x, :height}
  #--------------------------------------------------------------------------
  def process_escape_character(code, text, pos)
    case code.upcase
    when '$'
      @gold_window.open
    when '.'
      wait(15)
    when '|'
      wait(60)
    when '!'
      input_pause
    when '>'
      @line_show_fast = true
    when '<'
      @line_show_fast = false
    when '^'
      @pause_skip = true
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # ● 处理输入等待
  #--------------------------------------------------------------------------
  def input_pause
    self.pause = true
    wait(10)
    Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C)
    Input.update
    self.pause = false
  end
  #--------------------------------------------------------------------------
  # ● 处理选项的输入
  #--------------------------------------------------------------------------
  def input_choice
    @choice_window.start
    Fiber.yield while @choice_window.active
  end
  #--------------------------------------------------------------------------
  # ● 处理数值的输入
  #--------------------------------------------------------------------------
  def input_number
    @number_window.start
    Fiber.yield while @number_window.active
  end
  #--------------------------------------------------------------------------
  # ● 处理物品的选择
  #--------------------------------------------------------------------------
  def input_item
    @item_window.start
    Fiber.yield while @item_window.active
  end
end





window_face:




class Window_Face < Window_Base

        def initialize
                super(0, 0, 96 + 2 * standard_padding, 96 + 2 * standard_padding)
                self.z = 200
                self.visible = false
                fukiId = -1
        end

        def update_placement(x,y,height,down)
                self.x = x - self.width
                if !down
                        self.y = y + height - self.height
                else
                        self.y = y
                end
        end

        def draw_face
                super($game_message.face_name, $game_message.face_index, 0, 0)
        end

        def need_show(fukiId)
                if fukiId == -1
                  false
                else
                  $game_message.face_name.empty? ? false : true
                end
    end
end




怎么改!!..急!!!



Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9397
在线时间
2748 小时
注册时间
2008-9-5
帖子
3543

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

2
发表于 2016-10-2 23:11:33 | 只看该作者
draw_face方法的super上面加一行clear:

def draw_face
  contents.clear if contents
  super($game_message.face_name, $game_message.face_index, 0, 0)
end

评分

参与人数 1星屑 +250 梦石 +1 收起 理由
RaidenInfinity + 250 + 1 楼主认可的解答

查看全部评分

回复 支持 1 反对 0

使用道具 举报

Lv4.逐梦者

梦石
8
星屑
4801
在线时间
1567 小时
注册时间
2014-1-9
帖子
402

开拓者

3
 楼主| 发表于 2016-10-3 14:52:43 | 只看该作者
感谢大大,解决了
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-11-16 21:31

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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