Project1

标题: 强制关闭窗体提示是否关闭的功能 [打印本页]

作者: swbsl    时间: 2016-7-15 19:50
标题: 强制关闭窗体提示是否关闭的功能
我重写了 exit 的方法,只不过方法内部的其他函数都是照搬 Scene_End 和 Scene_Base 的。
实际测试的时候,提示窗口正常呼出,可以选择,就是按下了没反应。
劳烦诸位帮我看下问题出在哪里。谢谢!
代码如下:


module Kernel
  def exit(*args)
    main
  end
  
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
  def main
    start
    perform_transition
    post_start      
    Input.update         
    loop do
      Graphics.update      
      Input.update         
      update               
#      break if $scene != self   
    end
    Graphics.update
    pre_terminate               
    Graphics.freeze              
    terminate                  
  end
#--------------------------------------------------------------------------
# * Start processing
#--------------------------------------------------------------------------
  def start
    create_menu_background
    create_command_window   
  end
#--------------------------------------------------------------------------
# * Execute Transition
#--------------------------------------------------------------------------
  def perform_transition
    Graphics.transition(10)
  end
#--------------------------------------------------------------------------
# * Post-Start Processing
#--------------------------------------------------------------------------
  def post_start
    open_command_window
  end
#--------------------------------------------------------------------------
# * Return to Original Screen
#--------------------------------------------------------------------------
  def return_scene
    $scene = Scene_Menu.new(5)
  end  
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
  def update
   update_menu_background
    @command_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      return_scene
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0
        command_shutdown
      when 1
        command_cancel
      end
    end   
  end
#--------------------------------------------------------------------------
# * Create Command Window
#--------------------------------------------------------------------------  
def create_command_window
    s1 = "      退出"
    s2 = "      取消"
    @command_window = Window_Command.new(172, [s1, s2])
    @command_window.x = (544 - @command_window.width) / 2
    @command_window.y = (416 - @command_window.height) / 2
    @command_window.openness = 0
  end
#--------------------------------------------------------------------------
# * Dispose of Command Window
#--------------------------------------------------------------------------
  def dispose_command_window
    @command_window.dispose
  end
#--------------------------------------------------------------------------
# * Open Command Window
#--------------------------------------------------------------------------
  def open_command_window
    @command_window.open
    begin
      @command_window.update
      Graphics.update
    end until @command_window.openness == 255
  end
#--------------------------------------------------------------------------
# * Close Command Window
#--------------------------------------------------------------------------
  def close_command_window
    @command_window.close
    begin
      @command_window.update
      Graphics.update
    end until @command_window.openness == 0
  end  
#--------------------------------------------------------------------------
# * Pre-termination Processing
#--------------------------------------------------------------------------
  def pre_terminate
    close_command_window
  end
#--------------------------------------------------------------------------
# * Process When Choosing [Shutdown] Command
#--------------------------------------------------------------------------
  def command_shutdown
    Sound.play_decision
    RPG::BGM.fade(800)
    RPG::BGS.fade(800)
    RPG::ME.fade(800)
    $scene = nil
  end
#--------------------------------------------------------------------------
# *  Process When Choosing [Cancel] Command
#--------------------------------------------------------------------------
  def command_cancel
    Sound.play_decision
    return_scene
  end  
#--------------------------------------------------------------------------
# * Termination Processing
#--------------------------------------------------------------------------
  def terminate
    dispose_command_window
    dispose_menu_background   
  end
#--------------------------------------------------------------------------
# * Create Snapshot for Using as Background of Another Screen
#--------------------------------------------------------------------------
  def snapshot_for_background
    $game_temp.background_bitmap.dispose
    $game_temp.background_bitmap = Graphics.snap_to_bitmap
    $game_temp.background_bitmap.blur
  end
#--------------------------------------------------------------------------
# * Create Background for Menu Screen
#--------------------------------------------------------------------------
  def create_menu_background
    @menuback_sprite = Sprite.new
    @menuback_sprite.bitmap = $game_temp.background_bitmap
    @menuback_sprite.color.set(16, 16, 16, 128)
    update_menu_background
  end
#--------------------------------------------------------------------------
# * Dispose of Background for Menu Screen
#--------------------------------------------------------------------------
  def dispose_menu_background
    @menuback_sprite.dispose
  end
#--------------------------------------------------------------------------
# * Update Background for Menu Screen
#--------------------------------------------------------------------------
  def update_menu_background
    @menuback_sprite.tone.set(0, 0, 0, 128)   
  end  
  
end






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