Project1

标题: 自製選項窗口出現"Game.exe發生問題"該如何解決? [打印本页]

作者: nuitjean    时间: 2010-8-3 22:24
标题: 自製選項窗口出現"Game.exe發生問題"該如何解決?
本帖最后由 nuitjean 于 2010-8-4 11:19 编辑

選項窗口腳本

  1. class Window_Choice < Window_Base
  2.   #快速定義2個名為index方法
  3.   attr_accessor :index
  4.   def initialize
  5.     #窗口(X座標, Y座標, 寬度, 高度)       #資料庫變數"選項Max+1"
  6.     super(640/2-16-(25 *$game_variables[15]/2), 480/2-16 - (($game_variables[8] + 2)*32 / 2), 25 *$game_variables[15], ($game_variables[8] + 2)*32  )
  7.     self.contents = Bitmap.new(width - 32, height - 32)
  8.     #窗口不透明度 #不透明度
  9.     self.opacity = 0
  10.     #背景生成
  11.     #@sprite = Sprite.new
  12.     #@sprite.bitmap = RPG::Cache.picture("Menu-back")
  13.     #
  14.     #背景生成(以地圖當背景
  15.     @mapbg = Spriteset_Map.new

  16.   #定義名為index的實例變量代入數值0
  17.     @index = 0
  18.   #呼叫這個方法來顯示游標
  19.     refresh
  20.   end
  21.   #定義update_cursor_rect方法
  22.   def refresh
  23.     self.contents.clear
  24.     self.contents.font.color = normal_color    #資料庫變數"選項1內容" #靠邊 0左邊1中央2右邊
  25.         self.contents.draw_text(0, 0, 160, 32, $game_variables[9] , 1)
  26.         self.contents.draw_text(0, 32, 160, 32, $game_variables[10] , 1)
  27.      if $game_variables[8] >= 2
  28.         self.contents.draw_text(0, 64, 160, 32, $game_variables[11] , 1)
  29.      end
  30.      if $game_variables[8] >= 3
  31.         self.contents.draw_text(0, 96, 160, 32, $game_variables[12] , 1)
  32.      end
  33.      if $game_variables[8] >= 4
  34.         self.contents.draw_text(0, 128, 160, 32, $game_variables[13] , 1)
  35.      end
  36.      if $game_variables[8] >= 5
  37.         self.contents.draw_text(0, 160, 160, 32, $game_variables[14] , 1)
  38.      end

  39.   #呼叫這個方法來顯示游標
  40.     update_cursor_rect
  41.   end
  42.   #定義update_cursor_rect方法
  43.   def update_cursor_rect
  44.                        #(X座標, Y座標, 寬度, 高度)
  45.     self.cursor_rect.set(0, 32 * @index, 20 *$game_variables[15] , 32)
  46.   end
  47. end
复制代码
選項腳本
  1. class Scene_Choice
  2.   def main
  3.     @sword_window = Window_Choice.new
  4.     Graphics.transition
  5.     loop do
  6.       Graphics.update
  7.       Input.update
  8.       update
  9.       if $scene != self
  10.         break
  11.       end
  12.     end
  13.     Graphics.freeze
  14.     @sword_window.dispose
  15.   end
  16.   def update
  17.     #更新選項游標
  18.     @sword_window.update
  19.     #條件分歧:當'按鍵 上'被按下時執行的場合
  20.     if Input.trigger?(Input::UP)
  21.       #當選項位置(@index) 等於 0(第1個選項)的場合時
  22.       if @sword_window.index == 0
  23.         #按下 上鍵 回到最後的選項
  24.         @sword_window.index = $game_variables[8]
  25.       else
  26.         @sword_window.index -= 1
  27.         Audio.se_play("Audio/SE/" + "001-System01", 100, 100)
  28.       end
  29.       #這個是當在第1個選項時按下上鍵時執行的內容...
  30.       @sword_window.update_cursor_rect
  31.     end
  32.     #條件分歧:當'按鍵 下'被按下時執行的場合
  33.     if Input.trigger?(Input::DOWN)
  34.       #當選項位置(@index) 等於 3(第3個選項)的場合時
  35.       if @sword_window.index == $game_variables[8]
  36.         #按下 下鍵 回到最初的選項
  37.         @sword_window.index = 0
  38.       else
  39.         @sword_window.index += 1
  40.         Audio.se_play("Audio/SE/" + "001-System01", 100, 100)
  41.       end
  42.       #這個是當在最後選項時按下下鍵時執行的內容...
  43.       @sword_window.update_cursor_rect
  44.     end
  45.     if Input.trigger?(Input::C)
  46.       case @sword_window.index
  47.       when 0
  48.         #p '你選擇了選項1'
  49.         $game_variables[8] = 1
  50.         $game_map.events[$game_variables[15]].start
  51.         $scene = Scene_Map.new
  52.       when 1
  53.         #p '你選擇了選項2'
  54.         $game_variables[8] = 2
  55.       when 2
  56.         if $game_variables[8] >= 2
  57.          $game_variables[8] = 3
  58.       #執行地圖事件
  59.       #$game_map.events[$game_variables[15]].start
  60.       #回到地圖
  61.       #$scene = Scene_Map.new
  62.         end
  63.       when 3
  64.         if $game_variables[8] >= 3
  65.          $game_variables[8] = 4
  66.         end
  67.       when 4
  68.         if $game_variables[8] >= 4
  69.          $game_variables[8] = 5
  70.         end
  71.       when 5
  72.         if $game_variables[8] >= 5
  73.          $game_variables[8] = 6
  74.         end
  75.       end
  76.       Audio.se_play("Audio/SE/" + "002-System02", 100, 100)
  77.     end
  78.   end
  79. end
复制代码
事件設置



執行事件後,選擇第1個選項就出現Game.exe發生問題而強制關閉了......
請問該如何解決此問題呢?
作者: zhixin1997    时间: 2010-8-4 09:17
您检查下“脚本编辑器”里脚本是否过多
或者是当前的脚本拼写哪里出错了?
作者: nuitjean    时间: 2010-8-4 11:18
回复 zhixin1997 的帖子
謝謝.
我找到了...是這句出了問題
$game_map.events[$game_variables[15]].start
改成
i = 1
$game_map.events.start
就ok了!
不過會和66rpg的真‧對話加強腳本1.12版沖突......
   




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