赞 | 0 |
VIP | 0 |
好人卡 | 2 |
积分 | 11 |
经验 | 1937 |
最后登录 | 2012-6-16 |
在线时间 | 274 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1145
- 在线时间
- 274 小时
- 注册时间
- 2011-7-24
- 帖子
- 272
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
- #================================================= =============================
- # ** Pause Game
- #------------------------------------------------------------------------------
- # © Dargor, 2008
- # 17/06/08
- # Version 1.0
- #------------------------------------------------------------------------------
- # VERSION HISTORY:
- # - 1.0 (17/05/08), Initial release
- # - 1.1 (17/05/08), Added "Stack Reset" prevention
- #------------------------------------------------------------------------------
- # INSTRUCTIONS:
- # - Paste this above main
- # - Edit the constants in the Pause_Game module
- #------------------------------------------------------------------------------
- # NOTES:
- # This script modifies the Graphics module and rewrites the main
- # method of Scene_Base.
- #================================================= =============================
- #================================================= =============================
- # ** Pause Game Configuration Module
- #================================================= =============================
- module Pause_Game
- # Scenes in which the Pause option will be enabled
- Allowed_Scenes = [Scene_Map, Scene_Battle]
- # Graphics Brightness when paused
- Graphics_Brightness = 160
- # BGM Volume when paused
- BGM_Volume = 70
- # Pause Key
- Key = Input::SHIFT
- # Pause window
- Pause_Window = true
- end
- #================================================= =============================
- # ** Graphics
- #------------------------------------------------------------------------------
- # This module carries out graphics processing.
- #================================================= =============================
- module Graphics
- class << self
- #--------------------------------------------------------------------------
- # * Alias Listing
- #--------------------------------------------------------------------------
- if @graphics_stack.nil?
- alias dargor_vx_pause_graphics_initialize initialize
- alias dargor_vx_pause_graphics_update update
- @graphics_stack = true
- end
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- @paused = false
- dargor_vx_pause_graphics_initialize
- end
- #--------------------------------------------------------------------------
- # * Pause
- #--------------------------------------------------------------------------
- def pause
- return @paused
- end
- #--------------------------------------------------------------------------
- # * Pause =
- #--------------------------------------------------------------------------
- def pause=(bool)
- # Set brightness and BGM volume
- if bool
- self.brightness = Pause_Game::Graphics_Brightness
- Sound.set_bgm_volume(Pause_Game::BGM_Volume)
- else
- self.brightness = 255
- Sound.reset_bgm_volume
- end
- # Refresh screen
- update
- # Set pause flag
- @paused = bool
- end
- #--------------------------------------------------------------------------
- # * Pause Disabled
- #--------------------------------------------------------------------------
- def pause_disabled?
- return !Pause_Game::Allowed_Scenes.include?($scene.class)
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- return if @paused
- dargor_vx_pause_graphics_update
- end
- end
- end
- #================================================= =============================
- # ** Sound
- #------------------------------------------------------------------------------
- # This module plays sound effects. It obtains sound effects specified in the
- # database from $data_system, and plays them.
- #================================================= =============================
- module Sound
- #--------------------------------------------------------------------------
- # * Set BGM Volume
- #--------------------------------------------------------------------------
- def self.set_bgm_volume(volume)
- RPG::BGM.last.last_volume = RPG::BGM.last.volume
- RPG::BGM.last.volume = volume
- RPG::BGM.last.play
- end
- #--------------------------------------------------------------------------
- # * Reset BGM Volume
- #--------------------------------------------------------------------------
- def self.reset_bgm_volume
- RPG::BGM.last.volume = RPG::BGM.last.last_volume
- RPG::BGM.last.play
- end
- end
- #================================================= =============================
- # ** RPG::AudioFile
- #------------------------------------------------------------------------------
- # Superclass of BGM, BGS, ME, and SE.
- #================================================= =============================
- class RPG::AudioFile
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :last_volume
- #--------------------------------------------------------------------------
- # * Alias Listing
- #--------------------------------------------------------------------------
- alias dargor_vx_pause_audiofile_initialize initialize
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(*args)
- dargor_vx_pause_audiofile_initialize
- @last_volume = @volume
- end
- end
- #================================================= =============================
- # ** Scene_Base
- #------------------------------------------------------------------------------
- # This is a superclass of all scenes in the game.
- #================================================= =============================
- class Scene_Base
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- start # Start processing
- perform_transition # Perform transition
- post_start # Post-start processing
- Input.update # Update input information
- loop do
- update_pause # Update game pause state
- Graphics.update # Update game screen
- Input.update # Update input information
- next if Graphics.pause # Cancel scene update if game is paused
- update # Update frame
- break if $scene != self # When screen is switched, interrupt loop
- end
- Graphics.update
- pre_terminate # Pre-termination processing
- Graphics.freeze # Prepare transition
- terminate # Termination processing
- end
- #--------------------------------------------------------------------------
- # * Frame Update (Pause)
- #--------------------------------------------------------------------------
- def update_pause
- # Update spriteset if it exists
- unless Graphics.pause
- terminate_pause_window
- end
- # Cancel pause update if pause is disabled
- return if Graphics.pause_disabled?
- # Update Pause effect
- if Input.trigger?(Pause_Game::Key)
- create_pause_window unless Graphics.pause
- Graphics.pause = !Graphics.pause
- return
- end
- end
- #--------------------------------------------------------------------------
- # * Create Pause Window
- #--------------------------------------------------------------------------
- def create_pause_window
- return unless @pause_window.nil?
- return unless Pause_Game:: Pause_Window
- @pause_window = Window_Help.new
- @pause_window.width = 272
- @pause_window.x = Graphics.width / 2 - @pause_window.width / 2
- @pause_window.y = Graphics.height / 2 - @pause_window.height / 2
- @pause_window.create_contents
- @pause_window.set_text('暂停...',1)
- end
- #--------------------------------------------------------------------------
- # * Terminate Pause Window
- #--------------------------------------------------------------------------
- def terminate_pause_window
- return if @pause_window.nil?
- @pause_window.dispose
- @pause_window = nil
- end
- end
复制代码 可以把游戏暂停一会..MS木有什么用
|
|