Granas3 REMIXED
Member
Will this one do? I didn't make it, nor am i 100% sure how works. The way it is set up now will pause when the player presses "a" on the keyboard, although it is called X in the script for some reason.
Code:
#┌───────────────────────────────────────
#│
#│ TRCS.19
#│ "ãƒãƒ¼ã‚ºç”»é¢" ver1.40 (2006.03.12 h22)
#│ by NO
#│ http://chobi.net/~no/
#│
#└───────────────────────────────────────
# BGMãŒãªã„å ´åˆã«ã‚‚対応
module TRCS19_STOPPING
#--------------------------------------------------------------------------
# â—‹ è¨å®šé …ç›®
#--------------------------------------------------------------------------
# ãƒãƒ¼ã‚ºãƒœã‚¿ãƒ³ (æ–‡å—列指定)
PAUSE_BUTTON = "X"
# ãƒãƒ¼ã‚ºãƒ†ã‚スト
PAUSE_TEXT = "Paused"
# ãƒãƒ¼ã‚º 開始SE
PAUSE_START_SE = ""
# ãƒãƒ¼ã‚º 終了SE
PAUSE_END_SE = ""
# ãƒãƒ¼ã‚ºãƒ†ã‚ストカラー
# → [R, G, B, alpha] ã§è¨å®š
PAUSE_TEXT_COLOR = [255, 255, 255, 255]
# ãƒãƒ¼ã‚ºæ™‚ã®èƒŒæ™¯è‰²
# → [R, G, B, alpha] ã§è¨å®š (通常時ã¨æ¯”ã¹ãŸç›¸å¯¾å€¤)
PAUSE_TONE = [-64, -64, -64, 0]
# ãƒãƒ¼ã‚ºæ™‚ã¯ãƒ—レイ時間をåœæ¢ã•ã›ã‚‹
# → YES = true, NO = false
STOP_TIME = false #allow/disallow freezing play time during pause
# ãƒãƒ¼ã‚ºä¸ã®éŸ³é‡ä½Žä¸‹çŽ‡(%指定)
VOL_DOWN_RATE = 50
# ãƒãƒ¼ã‚ºè¨±å¯ã‚¹ã‚¤ãƒƒãƒå
# → スイッãƒIDを指定ã™ã‚‹ã“ã¨ã‚‚å¯èƒ½
PAUSE_SW_NAME = "ãƒãƒ¼ã‚ºè¨±å¯" #Set a switch name to allow/disallow pause
# ãƒãƒ¼ã‚ºãƒœã‚¿ãƒ³å®šç¾©
PAUSE_BUTTON2 = eval("Input::#{PAUSE_BUTTON}")
#--------------------------------------------------------------------------
# â—‹ ç”»é¢åœæ¢
#--------------------------------------------------------------------------
def stopping
# SE ã‚’æ¼”å¥
Audio.se_play("Audio/SE/" + PAUSE_START_SE) if !PAUSE_START_SE.empty?
# BGMãŒæ¼”å¥ä¸ã®å ´åˆ
if $game_system.playing_bgm != nil and !$game_system.playing_bgm.name.empty?
# æ¼”å¥ä¸BGMã®éŸ³é‡ã‚’退é¿
dummy_vol = $game_system.playing_bgm.volume
# 音é‡ã‚’下ã’ã¦æ¼”å¥
new_vol = (dummy_vol * VOL_DOWN_RATE / 100).to_i
Audio.bgm_play("Audio/BGM/" + $game_system.playing_bgm.name, new_vol)
end
# ç¾åœ¨ã®è‰²èª¿ã‚’退é¿
dummy_tone = $game_screen.tone.clone
# ビューãƒãƒ¼ãƒˆã®ä½œæˆ
viewport1 = Viewport.new(0, 0, 640, 480)
viewport1.z = 10000
viewport1.tone = Tone.new(*PAUSE_TONE)
# フィルター用スプライトã®ä½œæˆ
sprite1 = Sprite.new(viewport1)
sprite1.tone = Tone.new(0, 0, 0, 0)
sprite1.bitmap = Bitmap.new(640, 480)
# æ–‡å—サイズ決定
width = sprite1.bitmap.text_size(PAUSE_TEXT).width
# ビューãƒãƒ¼ãƒˆã®ä½œæˆ
viewport2 = Viewport.new((640 - width) / 2, (480 - 32) / 2, width, 32)
viewport2.z = 10000
# æ–‡å—用スプライトã®ä½œæˆ
sprite2 = Sprite.new(viewport2)
sprite2.bitmap = Bitmap.new(width, 32)
# æ–‡å—æç”»
sprite2.bitmap.font = Font.new
sprite2.bitmap.font.color = Color.new(*PAUSE_TEXT_COLOR)
sprite2.bitmap.draw_text(0, 0, width, 32, PAUSE_TEXT)
# メインループ
loop do
# ゲーム画é¢ã‚’æ›´æ–°
Graphics.update
# å…¥åŠ›æƒ…å ±ã‚’æ›´æ–°
Input.update
# ボタンãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
if Input.trigger?(PAUSE_BUTTON2)
# SE ã‚’æ¼”å¥
Audio.se_play("Audio/SE/" + PAUSE_START_SE) if !PAUSE_START_SE.empty?
# BGMãŒæ¼”å¥ä¸ã®å ´åˆ
if $game_system.playing_bgm != nil and !$game_system.playing_bgm.name.empty?
# 音é‡ã‚’戻ã—ã¦æ¼”å¥
Audio.bgm_play("Audio/BGM/" + $game_system.playing_bgm.name, dummy_vol)
end
# ループ脱出
break
end
end
# 色調を元ã«æˆ»ã™
sprite1.viewport.tone = dummy_tone
# 解放
sprite1.dispose
sprite2.dispose
sprite1 = nil
sprite2 = nil
end
#--------------------------------------------------------------------------
# â—‹ ç”»é¢åœæ¢ãŒå¯èƒ½ã‹
#--------------------------------------------------------------------------
def can_stop?
if PAUSE_SW_NAME.is_a?(Numeric)
return ($game_switches[PAUSE_SW_NAME] rescue true)
else
return ($game_switches[$data_system.switches.index(PAUSE_SW_NAME)] rescue true)
end
end
end
#==============================================================================
# â– Scene_Map
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# ○ インクルード
#--------------------------------------------------------------------------
include TRCS19_STOPPING
#--------------------------------------------------------------------------
# ○ フレーム更新
#--------------------------------------------------------------------------
alias trcs19_update update
def update
# ボタンãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
if Input.trigger?(PAUSE_BUTTON2) and can_stop?
# フレームカウントを退é¿
tmp = Graphics.frame_count
# ç”»é¢åœæ¢
stopping
# ãƒãƒ¼ã‚ºä¸ã¯ãƒ—レイ時間を進ã‚ãªã„å ´åˆ
if STOP_TIME
# フレームカウントを修æ£
Graphics.frame_count = tmp
end
end
# 呼ã³æˆ»ã™
trcs19_update
end
end
#==============================================================================
# â– Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# ○ インクルード
#--------------------------------------------------------------------------
include TRCS19_STOPPING
#--------------------------------------------------------------------------
# ○ フレーム更新
#--------------------------------------------------------------------------
alias trcs19_update update
def update
# ボタンãŒæŠ¼ã•ã‚ŒãŸå ´åˆ
if Input.trigger?(PAUSE_BUTTON2) and can_stop?
# フレームカウントを退é¿
tmp = Graphics.frame_count
# ç”»é¢åœæ¢
stopping
# ãƒãƒ¼ã‚ºä¸ã¯ãƒ—レイ時間を進ã‚ãªã„å ´åˆ
if STOP_TIME
# フレームカウントを修æ£
Graphics.frame_count = tmp
end
end
# 呼ã³æˆ»ã™
trcs19_update
end
end