设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2615|回复: 1
打印 上一主题 下一主题

[转载] 暂停游戏..

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1105
在线时间
274 小时
注册时间
2011-7-24
帖子
272
跳转到指定楼层
1
发表于 2011-9-24 20:04:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
  1. #================================================= =============================
  2. # ** Pause Game
  3. #------------------------------------------------------------------------------
  4. # © Dargor, 2008
  5. # 17/06/08
  6. # Version 1.0
  7. #------------------------------------------------------------------------------
  8. # VERSION HISTORY:
  9. # - 1.0 (17/05/08), Initial release
  10. # - 1.1 (17/05/08), Added "Stack Reset" prevention
  11. #------------------------------------------------------------------------------
  12. # INSTRUCTIONS:
  13. # - Paste this above main
  14. # - Edit the constants in the Pause_Game module
  15. #------------------------------------------------------------------------------
  16. # NOTES:
  17. # This script modifies the Graphics module and rewrites the main
  18. # method of Scene_Base.
  19. #================================================= =============================

  20. #================================================= =============================
  21. # ** Pause Game Configuration Module
  22. #================================================= =============================

  23. module Pause_Game
  24. # Scenes in which the Pause option will be enabled
  25. Allowed_Scenes = [Scene_Map, Scene_Battle]
  26. # Graphics Brightness when paused
  27. Graphics_Brightness = 160
  28. # BGM Volume when paused
  29. BGM_Volume = 70
  30. # Pause Key
  31. Key = Input::SHIFT
  32. # Pause window
  33. Pause_Window = true
  34. end

  35. #================================================= =============================
  36. # ** Graphics
  37. #------------------------------------------------------------------------------
  38. # This module carries out graphics processing.
  39. #================================================= =============================

  40. module Graphics
  41. class << self
  42. #--------------------------------------------------------------------------
  43. # * Alias Listing
  44. #--------------------------------------------------------------------------
  45. if @graphics_stack.nil?
  46. alias dargor_vx_pause_graphics_initialize initialize
  47. alias dargor_vx_pause_graphics_update update
  48. @graphics_stack = true
  49. end
  50. #--------------------------------------------------------------------------
  51. # * Object Initialization
  52. #--------------------------------------------------------------------------
  53. def initialize
  54. @paused = false
  55. dargor_vx_pause_graphics_initialize
  56. end
  57. #--------------------------------------------------------------------------
  58. # * Pause
  59. #--------------------------------------------------------------------------
  60. def pause
  61. return @paused
  62. end
  63. #--------------------------------------------------------------------------
  64. # * Pause =
  65. #--------------------------------------------------------------------------
  66. def pause=(bool)
  67. # Set brightness and BGM volume
  68. if bool
  69. self.brightness = Pause_Game::Graphics_Brightness
  70. Sound.set_bgm_volume(Pause_Game::BGM_Volume)
  71. else
  72. self.brightness = 255
  73. Sound.reset_bgm_volume
  74. end
  75. # Refresh screen
  76. update
  77. # Set pause flag
  78. @paused = bool
  79. end
  80. #--------------------------------------------------------------------------
  81. # * Pause Disabled
  82. #--------------------------------------------------------------------------
  83. def pause_disabled?
  84. return !Pause_Game::Allowed_Scenes.include?($scene.class)
  85. end
  86. #--------------------------------------------------------------------------
  87. # * Frame Update
  88. #--------------------------------------------------------------------------
  89. def update
  90. return if @paused
  91. dargor_vx_pause_graphics_update
  92. end
  93. end
  94. end

  95. #================================================= =============================
  96. # ** Sound
  97. #------------------------------------------------------------------------------
  98. # This module plays sound effects. It obtains sound effects specified in the
  99. # database from $data_system, and plays them.
  100. #================================================= =============================

  101. module Sound
  102. #--------------------------------------------------------------------------
  103. # * Set BGM Volume
  104. #--------------------------------------------------------------------------
  105. def self.set_bgm_volume(volume)
  106. RPG::BGM.last.last_volume = RPG::BGM.last.volume
  107. RPG::BGM.last.volume = volume
  108. RPG::BGM.last.play
  109. end
  110. #--------------------------------------------------------------------------
  111. # * Reset BGM Volume
  112. #--------------------------------------------------------------------------
  113. def self.reset_bgm_volume
  114. RPG::BGM.last.volume = RPG::BGM.last.last_volume
  115. RPG::BGM.last.play
  116. end
  117. end

  118. #================================================= =============================
  119. # ** RPG::AudioFile
  120. #------------------------------------------------------------------------------
  121. # Superclass of BGM, BGS, ME, and SE.
  122. #================================================= =============================

  123. class RPG::AudioFile
  124. #--------------------------------------------------------------------------
  125. # * Public Instance Variables
  126. #--------------------------------------------------------------------------
  127. attr_accessor :last_volume
  128. #--------------------------------------------------------------------------
  129. # * Alias Listing
  130. #--------------------------------------------------------------------------
  131. alias dargor_vx_pause_audiofile_initialize initialize
  132. #--------------------------------------------------------------------------
  133. # * Object Initialization
  134. #--------------------------------------------------------------------------
  135. def initialize(*args)
  136. dargor_vx_pause_audiofile_initialize
  137. @last_volume = @volume
  138. end
  139. end

  140. #================================================= =============================
  141. # ** Scene_Base
  142. #------------------------------------------------------------------------------
  143. # This is a superclass of all scenes in the game.
  144. #================================================= =============================

  145. class Scene_Base
  146. #--------------------------------------------------------------------------
  147. # * Main Processing
  148. #--------------------------------------------------------------------------
  149. def main
  150. start # Start processing
  151. perform_transition # Perform transition
  152. post_start # Post-start processing
  153. Input.update # Update input information
  154. loop do
  155. update_pause # Update game pause state
  156. Graphics.update # Update game screen
  157. Input.update # Update input information
  158. next if Graphics.pause # Cancel scene update if game is paused
  159. update # Update frame
  160. break if $scene != self # When screen is switched, interrupt loop
  161. end
  162. Graphics.update
  163. pre_terminate # Pre-termination processing
  164. Graphics.freeze # Prepare transition
  165. terminate # Termination processing
  166. end
  167. #--------------------------------------------------------------------------
  168. # * Frame Update (Pause)
  169. #--------------------------------------------------------------------------
  170. def update_pause
  171. # Update spriteset if it exists
  172. unless Graphics.pause
  173. terminate_pause_window
  174. end
  175. # Cancel pause update if pause is disabled
  176. return if Graphics.pause_disabled?
  177. # Update Pause effect
  178. if Input.trigger?(Pause_Game::Key)
  179. create_pause_window unless Graphics.pause
  180. Graphics.pause = !Graphics.pause
  181. return
  182. end
  183. end
  184. #--------------------------------------------------------------------------
  185. # * Create Pause Window
  186. #--------------------------------------------------------------------------
  187. def create_pause_window
  188. return unless @pause_window.nil?
  189. return unless Pause_Game:: Pause_Window
  190. @pause_window = Window_Help.new
  191. @pause_window.width = 272
  192. @pause_window.x = Graphics.width / 2 - @pause_window.width / 2
  193. @pause_window.y = Graphics.height / 2 - @pause_window.height / 2
  194. @pause_window.create_contents
  195. @pause_window.set_text('暂停...',1)
  196. end
  197. #--------------------------------------------------------------------------
  198. # * Terminate Pause Window
  199. #--------------------------------------------------------------------------
  200. def terminate_pause_window
  201. return if @pause_window.nil?
  202. @pause_window.dispose
  203. @pause_window = nil
  204. end
  205. end
复制代码
可以把游戏暂停一会..MS木有什么用

Lv1.梦旅人

梦石
0
星屑
48
在线时间
678 小时
注册时间
2010-8-11
帖子
1533
2
发表于 2011-9-25 01:33:20 | 只看该作者
这,很有用啊=w=
怎么没用=w=
收下了=w=
(Dargor?话说我有这个作者的其他脚本来着……)

点评

自我感觉用不着....毕竟VX没有什么后台运行之类的  发表于 2011-9-25 10:58
小艾工作室开张= =
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-29 14:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表