| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 2 |
| 经验 | |
| 最后登录 | 2017-12-10 |
| 在线时间 | 78 小时 |
- 梦石
- 0
- 星屑
- 235
- 在线时间
- 78 小时
- 注册时间
- 2010-7-1
- 回帖
- 46
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 abc1236762 于 2012-8-19 12:11 编辑
我改了Window_Status腳本之後,
整隊發生NoMethodError錯誤,
請問要如何解決?
錯誤如圖
修改過的腳本如下
Window_Status
- #==============================================================================
- # ■ Window_MenuStatus
- #------------------------------------------------------------------------------
- # 選單畫面中,顯示隊伍成員狀態的視窗
- #==============================================================================
- class Window_MenuStatus < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 定義案例變量
- #--------------------------------------------------------------------------
- attr_reader :pending_index # 保留位置(整隊用)
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, window_width, window_height)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 取得列數 #by DisillusionSky Chen from Facebook
- #--------------------------------------------------------------------------
- def col_max(line)
- case line
- when 1
- return 4
- when 2
- return (item_max - 4 < 0 ? 0 : item_max - 4)
- end
- end
- #--------------------------------------------------------------------------
- # ● 取得行間距的寬度 #
- #--------------------------------------------------------------------------
- def spacing
- return 0
- end
- #--------------------------------------------------------------------------
- # ● 取得專案數
- #--------------------------------------------------------------------------
- def item_max
- $game_party.members.size
- end
- #--------------------------------------------------------------------------
- # ● 取得專案的寬度 #by DisillusionSky Chen from Facebook
- #--------------------------------------------------------------------------
- def item_width(line)
- case line
- when 1
- return 180
- when 2
- def item_width_s
- return (window_width.to_f - standard_padding * 2) / col_max(2)
- end
- if item_width_s > 96
- return 96
- else
- item_width_s
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 取得專案的高度 #
- #--------------------------------------------------------------------------
- def item_height
- return 320
- end
- #--------------------------------------------------------------------------
- # ● 取得行數 #
- #--------------------------------------------------------------------------
- def row_max
- return 2
- end
- #--------------------------------------------------------------------------
- # ● 取得視窗的寬度 #
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width + standard_padding * 2
- end
- #--------------------------------------------------------------------------
- # ● 取得視窗的高度 #
- #--------------------------------------------------------------------------
- def window_height
- Graphics.height * 2
- end
- #--------------------------------------------------------------------------
- # ● 取得當前行 #by DisillusionSky Chen from Facebook
- #--------------------------------------------------------------------------
- def row
- index / col_max(1) > 0 ? 1 : 2 ### 避免選擇第二行過後時產生第三行以後的誤判
- end
- #--------------------------------------------------------------------------
- # ● 取得專案的繪制矩形 #by DisillusionSky Chen from Facebook
- #--------------------------------------------------------------------------
- # index >= col_max(1) --> 索引在第二行時
- def item_rect(index)
- rect = Rect.new
- rect.width = (index >= col_max(1) ? item_width(2) : item_width(1))### 專案矩形的寬度-該行的專案寬度
- rect.height = item_height
- unless index >= col_max(1) #索引在第一行時
- rect.x = index % col_max(1) * (item_width(1) + spacing)###
- else # 索引在第二行時
- rect.x = (index - col_max(1)) * (item_width(2) + spacing)###
- end
- rect.y = (index / col_max(1)>0 ? 1 : 0) * item_height###
- rect
- end
- #--------------------------------------------------------------------------
- # ● 游標向下搬移 #by DisillusionSky Chen from Facebook
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- if index < col_max(1)
- select(col_max(1))
- end
- end
- #--------------------------------------------------------------------------
- # ● 游標向上搬移 #by DisillusionSky Chen from Facebook
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- if index >= col_max(1)
- select(col_max(1)-1)
- end
- end
- #--------------------------------------------------------------------------
- # ● 游標向右搬移 #
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- if col_max(1) >= 2 && (index < item_max - 1 || (wrap && horizontal?))
- select((index + 1) % item_max)
- end
- end
- #--------------------------------------------------------------------------
- # ● 游標向左搬移 #
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- if col_max(1) >= 2 && (index > 0 || (wrap && horizontal?))
- select((index - 1 + item_max) % item_max)
- end
- end
- #--------------------------------------------------------------------------
- # ● 繪制備戰角色肖像圖 #
- # enabled : 有效的標志。false 的時候使用半透明效果繪制
- #--------------------------------------------------------------------------
- def draw_wait_face(face_name, face_index, x, y, enabled = true)
- bitmap = Cache.face(face_name)
- def face_index_x
- if item_width(2) < 96
- return (96 - item_width(2)) / 2
- else
- return 0
- end
- end
- def face_index_width
- if item_width(2) < 96
- return item_width(2)
- else
- return 96
- end
- end
- rect = Rect.new(face_index % 4 * 96 + face_index_x, face_index / 4 * 96, face_index_width, 96)
- contents.blt(x, y, bitmap, rect)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 繪制角色肖像圖 #
- #--------------------------------------------------------------------------
- def draw_wait_actor_face(actor, x, y, enabled = true)
- draw_wait_face(actor.face_name, actor.face_index, x, y, enabled)
- end
- #--------------------------------------------------------------------------
- # ● 繪制專案 #
- #--------------------------------------------------------------------------
- def draw_item(index)
- if index >= col_max(1)
- draw_item_small(index)
- else
- draw_item_large(index)
- end
- end
- #--------------------------------------------------------------------------
- # ● 繪制大專案 #
- #--------------------------------------------------------------------------
- def draw_item_large(index)
- actor = $game_party.members[index]
- enabled = $game_party.battle_members.include?(actor)
- rect = item_rect(index)
- draw_item_background(index)
- draw_actor_body(actor, rect.x, rect.y, enabled)
- draw_actor_name(actor, rect.x, rect.y + item_height - line_height * 4)
- draw_actor_level(actor, rect.x, rect.y + item_height - line_height * 3)
- draw_actor_icons(actor, rect.x + 120, rect.y + item_height - line_height * 3)
- draw_actor_class(actor, rect.x + 120, rect.y + item_height - line_height * 4)
- draw_actor_hp(actor, rect.x, rect.y + item_height - line_height * 2)
- draw_actor_mp(actor, rect.x, rect.y + item_height - line_height * 1)
- end
- #--------------------------------------------------------------------------
- # ● 繪制小專案 #
- #--------------------------------------------------------------------------
- def draw_item_small(index)
- actor = $game_party.members[index]
- enabled = $game_party.battle_members.include?(actor)
- rect = item_rect(index)
- draw_item_background(index)
- draw_wait_actor_face(actor, rect.x, rect.y, enabled)
- draw_actor_name(actor, rect.x, rect.y + line_height * 4)
- end
- #--------------------------------------------------------------------------
- # ● 繪制專案的背景
- #--------------------------------------------------------------------------
- def draw_item_background(index)
- if index == @pending_index
- contents.fill_rect(item_rect(index), pending_color)
- end
- end
- #--------------------------------------------------------------------------
- # ● 按下確定鍵時的處理
- #--------------------------------------------------------------------------
- def process_ok
- super
- $game_party.menu_actor = $game_party.members[index]
- end
- #--------------------------------------------------------------------------
- # ● 返回上一個選擇的位置
- #--------------------------------------------------------------------------
- def select_last
- select($game_party.menu_actor.index || 0)
- end
- #--------------------------------------------------------------------------
- # ● 設定保留位置(整隊用)
- #--------------------------------------------------------------------------
- def pending_index=(index)
- last_pending_index = @pending_index
- @pending_index = index
- redraw_item(@pending_index)
- redraw_item(last_pending_index)
- end
- end
复制代码
Sence_Menu
- #encoding:utf-8
- #==============================================================================
- # ■ Scene_Menu
- #------------------------------------------------------------------------------
- # 選單畫面
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 開始處理
- #--------------------------------------------------------------------------
- def start
- super
- create_command_window
- create_gold_window
- #create_info_window
- create_status_window
- end
- #--------------------------------------------------------------------------
- # ● 生成指令視窗 #
- #--------------------------------------------------------------------------
- def create_command_window
- @command_window = Window_MenuCommand.new
- @command_window.x = (Graphics.width - @command_window.width) / 2
- @command_window.y = 0 - 12
- @command_window.set_handler(:item, method(:command_item))
- @command_window.set_handler(:skill, method(:command_personal))
- @command_window.set_handler(:equip, method(:command_personal))
- @command_window.set_handler(:status, method(:command_personal))
- @command_window.set_handler(:formation, method(:command_formation))
- @command_window.set_handler(:save, method(:command_save))
- @command_window.set_handler(:game_end, method(:command_game_end))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- #--------------------------------------------------------------------------
- # ● 生成金錢視窗
- #--------------------------------------------------------------------------
- def create_gold_window
- @gold_window = Window_Gold.new
- @gold_window.x = 0
- @gold_window.y = Graphics.height - @gold_window.height
- end
- #--------------------------------------------------------------------------
- # ● 生成資訊視窗
- #--------------------------------------------------------------------------
- def create_info_window
- @info_window = Window_Info.new
- @info_window.x = (Graphics.width - @info_window.width) / 2
- @info_window.y = (Graphics.height - @info_window.height) / 2
- end
- #--------------------------------------------------------------------------
- # ● 生成狀態視窗 #
- #--------------------------------------------------------------------------
- def create_status_window
- @status_window = Window_MenuStatus.new(-12, @command_window.height)
- @status_window.hide
- end
- #--------------------------------------------------------------------------
- # ● 指令“物品”
- #--------------------------------------------------------------------------
- def command_item
- SceneManager.call(Scene_Item)
- end
- #--------------------------------------------------------------------------
- # ● 指令“技能”“裝備”“狀態” #
- #--------------------------------------------------------------------------
- def command_personal
- @status_window.show
- @status_window.select_last
- @status_window.activate
- @status_window.set_handler(:ok, method(:on_personal_ok))
- @status_window.set_handler(:cancel, method(:on_personal_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 指令“整隊” #
- #--------------------------------------------------------------------------
- def command_formation
- @status_window.show
- @status_window.select_last
- @status_window.activate
- @status_window.set_handler(:ok, method(:on_formation_ok))
- @status_window.set_handler(:cancel, method(:on_formation_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 指令“存檔”
- #--------------------------------------------------------------------------
- def command_save
- SceneManager.call(Scene_Save)
- end
- #--------------------------------------------------------------------------
- # ● 指令“結束游戲”
- #--------------------------------------------------------------------------
- def command_game_end
- SceneManager.call(Scene_End)
- end
- #--------------------------------------------------------------------------
- # ● 個人指令“確定”
- #--------------------------------------------------------------------------
- def on_personal_ok
- case @command_window.current_symbol
- when :skill
- SceneManager.call(Scene_Skill)
- when :equip
- SceneManager.call(Scene_Equip)
- when :status
- SceneManager.call(Scene_Status)
- end
- end
- #--------------------------------------------------------------------------
- # ● 個人指令“取消” #
- #--------------------------------------------------------------------------
- def on_personal_cancel
- @status_window.unselect
- @status_window.hide
- @command_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 整隊“確定” #
- #--------------------------------------------------------------------------
- def on_formation_ok
- if @status_window.pending_index >= 0
- $game_party.swap_order(@status_window.index,
- @status_window.pending_index)
- @status_window.pending_index = -1
- @status_window.redraw_item(@status_window.index)
- else
- @status_window.pending_index = @status_window.index
- end
- @status_window.activate
- end
- #--------------------------------------------------------------------------
- # ● 整隊“取消” #
- #--------------------------------------------------------------------------
- def on_formation_cancel
- if @status_window.pending_index >= 0
- @status_window.pending_index = -1
- @status_window.hide
- @status_window.activate
- else
- @status_window.unselect
- @status_window.hide
- @command_window.activate
- end
- end
- end
复制代码
已自行解決
在
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, window_width, window_height)
- refresh
- end
复制代码 [/pre]
漏掉了@pending_index = -1
應改成
- #--------------------------------------------------------------------------
- # ● 初始化物件
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, window_width, window_height)
- @pending_index = -1
- refresh
- end
复制代码 [/pre] |
|