Project1

标题: 关于头像问题,求助! [打印本页]

作者: ZYY3125    时间: 2013-5-3 13:52
标题: 关于头像问题,求助!
想要在战斗时显示头像。
小弟初学者,还不会怎么改脚本,复制了一个网上的脚本。
#encoding:utf-8
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
#  显示战斗画面同伴状态的窗口。
#==============================================================================

class Window_BattleStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 416, 128)
    self.contents.font.size = 18
    refresh
    self.active = false
  end
  #--------------------------------------------------------------------------
  # ● 释放
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    @item_max = $game_party.members.size
    for i in 0...@item_max
      draw_item(i)
    end
    draw_6Rface(@index) if @index >= 0
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    rect.x += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color = normal_color
    actor = $game_party.members[index]
    draw_actor_name(actor, 124, rect.y + 2)
    begin_x = self.contents.text_size(actor.name).width + 4
    draw_actor_state(actor, begin_x, rect.y, 24)
    draw_actor_hp(actor, 230, rect.y, 65)
    draw_actor_mp(actor, 310, rect.y, 65)
  end
  #--------------------------------------------------------------------------
  # ● 描绘人物头像
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_6Rface(index)
    rect = Rect.new(0, 0, 96, 96)
    self.contents.clear_rect(rect)
    actor = $game_party.members[index]
    draw_actor_face(actor, 0, 0, 96)
  end  
  #--------------------------------------------------------------------------
  # ● 设置光标的位置
  #     index : 新的光标位置
  #--------------------------------------------------------------------------
  def index=(index)
    @index = index
    update_cursor
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 获取项目描画矩形
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def item_rect(index)
    rect = Rect.new(0, 0, 0, 0)
    rect.width = contents.width - 113
    rect.height = WLH
    rect.x = 113
    rect.y = index / @column_max * WLH
    return rect
  end  
  #--------------------------------------------------------------------------
  # ● 更新光标矩形
  #--------------------------------------------------------------------------
  def update_cursor
    if @index < 0                   # 光标位置不满 0 的情况下
      self.cursor_rect.empty        # 光标无效
    else                            # 光标位 0 以上的情况下
      row = @index / @column_max    # 获取当前的行
      if row < top_row              # 当前行被显示开头行前面的情况下
        self.top_row = row          # 从当前行向开头行滚动
      end
      if row > bottom_row           # 当前行被显示末尾行之后的情况下
        self.bottom_row = row       # 从当前行向末尾滚动
      end
      rect = item_rect(@index)      # 获取选择项的矩形
      rect.y -= self.oy             # 矩形滚动的位置加起来
      self.cursor_rect = rect       # 更新光标矩形
  end
#==============================================================================

  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width - 128
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的高度
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(visible_line_number)
  end
  #--------------------------------------------------------------------------
  # ● 获取显示行数
  #--------------------------------------------------------------------------
  def visible_line_number
    return 4
  end
  #--------------------------------------------------------------------------
  # ● 获取项目数
  #--------------------------------------------------------------------------
  def item_max
    $game_party.battle_members.size
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # ● 绘制项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    actor = $game_party.battle_members[index]
    draw_basic_area(basic_area_rect(index), actor)
    draw_gauge_area(gauge_area_rect(index), actor)
  end
  #--------------------------------------------------------------------------
  # ● 获取基本区域的矩形
  #--------------------------------------------------------------------------
  def basic_area_rect(index)
    rect = item_rect_for_text(index)
    rect.width -= gauge_area_width + 10
    rect
  end
  #--------------------------------------------------------------------------
  # ● 获取值槽区域的矩形
  #--------------------------------------------------------------------------
  def gauge_area_rect(index)
    rect = item_rect_for_text(index)
    rect.x += rect.width - gauge_area_width
    rect.width = gauge_area_width
    rect
  end
  #--------------------------------------------------------------------------
  # ● 获取值槽区域的宽度
  #--------------------------------------------------------------------------
  def gauge_area_width
    return 220
  end
  #--------------------------------------------------------------------------
  # ● 绘制基本区域
  #--------------------------------------------------------------------------
  def draw_basic_area(rect, actor)
    draw_actor_name(actor, rect.x + 0, rect.y, 100)
    draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
  end
  #--------------------------------------------------------------------------
  # ● 绘制值槽区域
  #--------------------------------------------------------------------------
  def draw_gauge_area(rect, actor)
    if $data_system.opt_display_tp
      draw_gauge_area_with_tp(rect, actor)
    else
      draw_gauge_area_without_tp(rect, actor)
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制值槽区域(包括 TP)
  #--------------------------------------------------------------------------
  def draw_gauge_area_with_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 72)
    draw_actor_mp(actor, rect.x + 82, rect.y, 64)
    draw_actor_tp(actor, rect.x + 156, rect.y, 64)
  end
  #--------------------------------------------------------------------------
  # ● 绘制值槽区域(不包括 TP)
  #--------------------------------------------------------------------------
  def draw_gauge_area_without_tp(rect, actor)
    draw_actor_hp(actor, rect.x + 0, rect.y, 134)
    draw_actor_mp(actor, rect.x + 144,  rect.y, 76)
  end
end
然后就悲剧了,不知为何总是启动不了,就说我的end有问题是什么unexpect end之类的。
作者: j433463    时间: 2013-5-3 14:34
更新光标矩形 def update_cursor 最后少了一个 end

您这脚本有问题,应该有配套的另一个以上的脚本,因为加了 end 后执行还是显示错误讯息,

第 78 行的 WLH 常量不知从何而来,第 80 行也用到这个 WLH 常量,但脚本中找不到它的初始定义,

测试检查脚本错误很累人的。
作者: ZYY3125    时间: 2013-5-3 14:55
j433463 发表于 2013-5-3 14:34
更新光标矩形 def update_cursor 最后少了一个 end

您这脚本有问题,应该有配套的另一个以上的脚本,因为 ...

请教大神改如何修改才能显示头像?
小弟不大会脚本,小弟只想求显示头像的方法啊……
谢谢大神指导了!
作者: j433463    时间: 2013-5-3 16:26
呃,在 6R 大概能搜索到的就是这个:

http://rpg.blue/thread-232288-1-1.html


作者: ZYY3125    时间: 2013-5-3 23:23
嗯,找了。
#encoding:utf-8
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
#  战斗画面中,显示“队伍成员状态”的窗口。
#==============================================================================

class Window_BattleStatus
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  alias super_refresh refresh
  def refresh
    super_refresh
    draw_face_emiya(@index) if @index >= 0
  end
  #--------------------------------------------------------------------------
  # ● 绘制人物头像
  #--------------------------------------------------------------------------
  def draw_face_emiya(index)
    rect = Rect.new(0, 0, 96, 96)
    self.contents.clear_rect(rect)
    actor = $game_party.battle_members[index]
    draw_actor_face(actor, 0, 0, true)
  end
  #--------------------------------------------------------------------------
  # ● 获取项目的绘制矩形
  #--------------------------------------------------------------------------
  alias super_item_rect item_rect
  def item_rect(index)
    rect = super_item_rect(index)
    if @index >= 0
      rect.width - 100;
      rect.x += 100
    end
    return rect
  end
  #--------------------------------------------------------------------------
  # ● 获取值槽区域的矩形
  #--------------------------------------------------------------------------
  alias super_gauge_area_rect gauge_area_rect
  def gauge_area_rect(index)
    rect = super_gauge_area_rect(index)
    rect.x -= 100 if @index >= 0
    return rect
  end
  #--------------------------------------------------------------------------
  # ● 更新光标
  #--------------------------------------------------------------------------
  alias super_update_cursor update_cursor
  def update_cursor
    super_update_cursor
    refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的宽度
  #--------------------------------------------------------------------------
  def window_width
    Graphics.width - 128
  end
  #--------------------------------------------------------------------------
  # ● 获取窗口的高度
  #--------------------------------------------------------------------------
  def window_height
    fitting_height(visible_line_number)
  end
  #--------------------------------------------------------------------------
  # ● 获取显示行数
  #--------------------------------------------------------------------------
  def visible_line_number
    return 4
  end
  #--------------------------------------------------------------------------
  # ● 获取项目数
  #--------------------------------------------------------------------------
  def item_max
    $game_party.battle_members.size
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # ● 绘制项目
  #--------------------------------------------------------------------------
  def draw_item(index)
    actor = $game_party.battle_members[index]
    draw_basic_area(basic_area_rect(index), actor)
    draw_gauge_area(gauge_area_rect(index), actor)
  end
  #--------------------------------------------------------------------------
  # ● 获取基本区域的矩形
  #--------------------------------------------------------------------------
  def basic_area_rect(index)
    rect = item_rect_for_text(index)
    rect.width -= gauge_area_width + 10
    rect
  end
  #--------------------------------------------------------------------------
  # ● 获取值槽区域的矩形
  #--------------------------------------------------------------------------
  def gauge_area_rect(index)
    rect = item_rect_for_text(index)
    rect.x += rect.width - gauge_area_width
    rect.width = gauge_area_width
    rect
  end
  #--------------------------------------------------------------------------
  # ● 获取值槽区域的宽度
  #--------------------------------------------------------------------------
  def gauge_area_width
    return 220
  end
  #--------------------------------------------------------------------------
  # ● 绘制基本区域
  #--------------------------------------------------------------------------
  def draw_basic_area(rect, actor)
    draw_actor_name(actor, rect.x + 0, rect.y, 100)
    draw_actor_icons(actor, rect.x + 104, rect.y, rect.width - 104)
  end
  #--------------------------------------------------------------------------
  # ● 绘制值槽区域
  #--------------------------------------------------------------------------
  def draw_gauge_area(rect, actor)
    if $data_system.opt_display_tp
      draw_gauge_area_with_tp(rect, actor)
    else
      draw_gauge_area_without_tp(rect, actor)
  end
但是还是出现问题,说是第十二行的问题。
请问大神第十二行出现什么情况了?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1