赞 | 13 |
VIP | 27 |
好人卡 | 24 |
积分 | 6 |
经验 | 58769 |
最后登录 | 2017-11-28 |
在线时间 | 795 小时 |
Lv2.观梦者 无节操
- 梦石
- 0
- 星屑
- 607
- 在线时间
- 795 小时
- 注册时间
- 2009-2-6
- 帖子
- 3939
|
本帖最后由 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
这个故事告诉我们,当你看到别人使用奇怪的方式实现一个东西的时候,总是有其原因的。(白目 |
评分
-
查看全部评分
|