Project1
标题:
请问如何在这个游戏暂停脚本中加入一个选项菜单
[打印本页]
作者:
PIA
时间:
2014-5-26 00:26
标题:
请问如何在这个游戏暂停脚本中加入一个选项菜单
就是下面这个脚本,我想要在按下暂停键后,屏幕中心显示一个选项窗口,里面的选项是“继续游戏”和“返回标题”,再次按下暂停键窗口消失且游戏恢复正常,请问要如何修改?
###############################################################################
#Pause Script Version 3
# Author: Unsigned_Zero
# Updated by Tsukihime
###############################################################################
# Pause picture should be placed in the Graphics/System folder
module U0_Pause_module
PAUSE_BUTTON = "B"
Pause_Picture = "Pause"
#dim the screen during pause
Dim_Screen = false
Dim_Brightness = 100
#The bgm to play when paused
Pause_Music = "1"
#The bgm volume when paused
Pause_Volume = 0
# Freeze Time when in pause mode?
TIME_STOP = true
PAUSE_BUTTON2 = eval("Input::#{PAUSE_BUTTON}")
PAUSE_OPACITY = 255 #opacity of the picture
def stopping
bgm = RPG::BGM.last
bgs = RPG::BGS.last
prev_brightness = Graphics.brightness
RPG::BGM.stop
Audio.bgm_play('Audio/BGM/' + Pause_Music, Pause_Volume)
viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport1.z = 10000
pause_sprite = Sprite.new(viewport1)
pause_sprite.tone = Tone.new(0, 0, 0, 0)
pause_sprite.bitmap = Cache.system (Pause_Picture)
pause_sprite.opacity = PAUSE_OPACITY
loop do
Graphics.update
Graphics.brightness = Dim_Brightness if Dim_Screen
Input.update
if Input.trigger?(PAUSE_BUTTON2)
break
end
end
Graphics.brightness = prev_brightness
bgm.play(bgm.pos)
bgs.play(bgs.pos)
pause_sprite.dispose
pause_sprite = nil
end
end
#==============================================================================
# Scene_Base
#==============================================================================
class Scene_Base
include U0_Pause_module
alias u0_pause_update update
def update
if Input.trigger?(PAUSE_BUTTON2)
frame = Graphics.frame_count
stopping
if TIME_STOP
Graphics.frame_count = frame
end
end
u0_pause_update
end
end
复制代码
作者:
moy
时间:
2014-5-26 02:07
本帖最后由 moy 于 2014-5-26 04:40 编辑
#==============================================================================
# ☆ Custom Adventure 简易暂停界面
# -- Last Updated: 2014.5.26
# -- by Moy
# -- 转载请保留以上信息
#==============================================================================
# 尽管除了module和scene_base部分已经和原来的脚本没有多大关系,还是@一下原作者
# @Unsigned_Zero和更新者@Tsukihime
# 顺便修复了点小bug,添加了点小功能,比如禁止循环调用,以及自由度更大的BGM和背景
#==============================================================================
module CA_PAUSE
PAUSE_BUTTON_NAME = "CTRL" # 暂停控制键名
DIM_SCREEN = true # 是否显示渐变
DIM_BRIGHTNESS = 100 # 渐变强度
PAUSE_PICTURE = "Pause" # 背景图文件名,存于System文件夹,false则截取屏幕为背景
PAUSE_OPACITY = 255 # 背景透明度,0~255
PAUSE_DARK = false # 背景是否变暗
PAUSE_MUSIC = "Airship" # BGM名,不需要更换则填false
PAUSE_VOLUME = 100 # BGM音量,100为常值,不更换BGM也可调整
PAUSE_PITCH = 100 # BGM音调,100为常值,不更换BGM也可调整
TIME_FREEZE = true # 暂停时是否冻结时间
PAUSE_BUTTON = eval("Input::#{PAUSE_BUTTON_NAME}") #暂停键的读取,可无视
end
#==============================================================================
# ■ BattleManager
#==============================================================================
module BattleManager
@battle_freeze = false
def self.battle_freeze=(value); @battle_freeze = value; end
def self.battle_freeze(); @battle_freeze; end
end
#==============================================================================
# ■ Scene_Base
#==============================================================================
class Scene_Base
include CA_PAUSE
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
alias ca_pause_update update
def update
if Input.trigger?(PAUSE_BUTTON)
frame = Graphics.frame_count
BattleManager.battle_freeze = true if self.is_a?(Scene_Battle)
SceneManager.call(Scene_Pause)
if TIME_FREEZE
Graphics.frame_count = frame
end
end
ca_pause_update
end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 战斗开始
#--------------------------------------------------------------------------
def battle_start
BattleManager.battle_start unless BattleManager.battle_freeze
BattleManager.battle_freeze = false
process_event
start_party_command_selection
end
end
#==============================================================================
# ■ Window_Pause
#==============================================================================
class Window_Pause < Window_Command
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0)
update_placement
self.openness = 0
open
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 更新窗口的位置
#--------------------------------------------------------------------------
def update_placement
self.x = (Graphics.width - width) / 2
self.y = (Graphics.height - height) / 2
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
add_command("返回游戏", :cancel)
add_command(Vocab::to_title, :to_title)
end
end
#==============================================================================
# ■ Scene_Pause
#==============================================================================
class Scene_Pause < Scene_Base
include CA_PAUSE
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
play_pause_music
create_background
create_command_window
end
#--------------------------------------------------------------------------
# ● 结束处理
#--------------------------------------------------------------------------
def terminate
super
dispose_background
end
#--------------------------------------------------------------------------
# ● 执行进入场景时的渐变
#--------------------------------------------------------------------------
def perform_transition
if DIM_SCREEN
Graphics.transition(DIM_BRIGHTNESS)
else
super
end
end
#--------------------------------------------------------------------------
# ● 更新画面 避免重复调用
#--------------------------------------------------------------------------
def update
ca_pause_update
end
#--------------------------------------------------------------------------
# ● 生成背景
#--------------------------------------------------------------------------
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = PAUSE_PICTURE ? Cache.system(PAUSE_PICTURE) : SceneManager.background_bitmap
@background_sprite.color.set(16, 16, 16, 128) if PAUSE_DARK
@background_sprite.opacity = PAUSE_OPACITY
end
#--------------------------------------------------------------------------
# ● 释放背景
#--------------------------------------------------------------------------
def dispose_background
@background_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 生成指令窗口
#--------------------------------------------------------------------------
def create_command_window
@command_window = Window_Pause.new
@command_window.set_handler(:cancel, method(:return_scene))
@command_window.set_handler(:to_title, method(:command_to_title))
end
#--------------------------------------------------------------------------
# ● 指令“返回标题”
#--------------------------------------------------------------------------
def command_to_title
close_command_window
fadeout_all
SceneManager.goto(Scene_Title)
end
#--------------------------------------------------------------------------
# ● 返回前一个场景
#--------------------------------------------------------------------------
def return_scene
play_last_music
SceneManager.return
end
#--------------------------------------------------------------------------
# ● 返回前一个场景
#--------------------------------------------------------------------------
def return_scene
BattleManager.protect_environment if self.is_a?(Scene_Battle)
SceneManager.return
end
#--------------------------------------------------------------------------
# ● 关闭指令窗口
#--------------------------------------------------------------------------
def close_command_window
@command_window.close
update until @command_window.close?
end
#--------------------------------------------------------------------------
# ● 播放暂停画面音乐
#--------------------------------------------------------------------------
def play_pause_music
@last_bgm = RPG::BGM.last
if PAUSE_MUSIC
Audio.bgm_play('Audio/BGM/' + PAUSE_MUSIC, PAUSE_VOLUME, PAUSE_PITCH)
else
Audio.bgm_play('Audio/BGM/' + @last_bgm.name , PAUSE_VOLUME, PAUSE_PITCH, @last_bgm.pos)
end
RPG::BGS.stop
RPG::ME.stop
end
#--------------------------------------------------------------------------
# ● 播放保存的音乐
#--------------------------------------------------------------------------
def play_last_music
Audio.bgm_play('Audio/BGM/' + @last_bgm.name , @last_bgm.volume, @last_bgm.pitch, @last_bgm.pos)
end
end
复制代码
基本照搬默认脚本的流程,我自己纯做个复习,顺便帮你完成了。就是改的几乎没有内容了,原作者真是抱歉啊|||不过加了些功能,也修复了一些bug,可安心233.
@Unsigned_Zero
@Tsukihime
[line]1[/line]
这个故事告诉我们,当你看到别人使用奇怪的方式实现一个东西的时候,总是有其原因的。(白目
作者:
PIA
时间:
2014-5-26 11:52
moy 发表于 2014-5-26 02:07
基本照搬默认脚本的流程,我自己纯做个复习,顺便帮你完成了。就是改的几乎没有内容了,原作者真是抱歉啊|| ...
亲测可以使用,非常感谢!
作者:
子弹君
时间:
2014-5-26 20:26
外站看到过这个脚本,然后..就没有然后了...
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1