class Scene_Changebgm<Scene_Base $ALLBGMMAX = 5 $NOWBGM = 1 #开始处理 def start super @changebgm = Bgm_change.new(0,0) create_background create_command_window end #结束处理 def terminate super @changebgm.dispose dispose_background close_command_window end #生成背景 def create_background @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(0, 0, 0, 128) end #释放背景 def dispose_background @background_sprite.dispose end #生成窗口指令 def create_command_window @changebgm.set_handler(:biaoti, method(:biaotiback)) @changebgm.set_handler(:last, method(:last)) @changebgm.set_handler(:next, method(:next)) @changebgm.set_handler(:savemusic, method(:savemusic)) end #关闭窗口指令 def close_command_window @changebgm.dispose end #返回标题画面 def biaotiback SceneManager.return end #上一首 def last if $NOWBGM != 1 $NOWBGM - 1 else $NOWBGM = 1 $NOWBGM = $ALLBGMMAX end playbgm end #下一首 def next if $NOWBGM != $ALLBGMMAX $NOWBGM + 1 else $NOWBGM = $ALLBGMMAX $NOWBGM = 1 end playbgm end #播放音乐 def playbgm bgmname = [ "","Audio/BGM/Theme1","Audio/BGM/Theme2","Audio/BGM/Theme3", "Audio/BGM/Theme4","Audio/BGM/Theme5" ] Audio.bgm_stop filename = bgmname[$NOWBGM] Audio.bgm_play(filename,100,70,0) SceneManager.goto(Scene_Changebgm) end #保存当前音乐(这个莫名其妙,好像没用?) def savemusic @game_system = Game_System.new @game_system.save_bgm Sound.play_save SceneManager.return end end
module Vocab ############################下面 Changebgm = "更换bgm" Next = "下一首" Last = "上一首" Backbiaoti = "返回标题" Onbgm = "选择音乐" Savemusic = "保存音乐" ##############################上面 end
class Window_TitleCommand < Window_Command #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize super(0, 0) update_placement select_symbol(:continue) if continue_enabled self.openness = 0 open end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # ● 更新窗口的位置 #-------------------------------------------------------------------------- def update_placement self.x = (Graphics.width - width) / 2 self.y = (Graphics.height * 1.6 - height) / 2 end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_command(Vocab::new_game, :new_game) add_command(Vocab::continue, :continue, continue_enabled) #############################################下面 add_command(Vocab::Changebgm,:changebgm) ###############################################上面 add_command(Vocab::shutdown, :shutdown) end #-------------------------------------------------------------------------- # ● 获取“继续游戏”选项是否有效 #-------------------------------------------------------------------------- def continue_enabled DataManager.save_file_exists? end end
class Bgm_change<Window_Command #####################################下面 def initialize(x,y) super self.openness = 0 open end def make_command_list add_command(Vocab::Backbiaoti, :biaoti) add_command(Vocab::Last, :last) add_command(Vocab::Next, :next) add_command(Vocab::Savemusic, :savemusic) end end ##########################################上面
class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super SceneManager.clear Graphics.freeze create_background create_foreground create_command_window play_title_music end #-------------------------------------------------------------------------- # ● 获取渐变速度 #-------------------------------------------------------------------------- def transition_speed return 20 end #-------------------------------------------------------------------------- # ● 结束处理 #-------------------------------------------------------------------------- def terminate super SceneManager.snapshot_for_background dispose_background dispose_foreground end #-------------------------------------------------------------------------- # ● 生成背景 #-------------------------------------------------------------------------- def create_background @sprite1 = Sprite.new @sprite1.bitmap = Cache.title1($data_system.title1_name) @sprite2 = Sprite.new @sprite2.bitmap = Cache.title2($data_system.title2_name) center_sprite(@sprite1) center_sprite(@sprite2) end #-------------------------------------------------------------------------- # ● 生成背景(gai) #-------------------------------------------------------------------------- def create_background beijing = rand(3) case beijing when 0 @beijingtwo = "Book" when 1 @beijingtwo = "Castle" when 2 @beijingtwo = "CrossedSwords" end @sprite1 = Sprite.new @sprite1.bitmap = Cache.title1($data_system.title1_name) @sprite1.bitmap = Cache.title1(@beijingtwo) @sprite2 = Sprite.new @sprite2.bitmap = Cache.title2($data_system.title2_name) center_sprite(@sprite1) center_sprite(@sprite2) end #-------------------------------------------------------------------------- # ● 生成前景 #-------------------------------------------------------------------------- def create_foreground @foreground_sprite = Sprite.new @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height) @foreground_sprite.z = 100 draw_game_title if $data_system.opt_draw_title end #-------------------------------------------------------------------------- # ● 绘制游戏标题 #-------------------------------------------------------------------------- def draw_game_title @foreground_sprite.bitmap.font.size = 48 rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2) @foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1) end #-------------------------------------------------------------------------- # ● 释放背景 #-------------------------------------------------------------------------- def dispose_background @sprite1.bitmap.dispose @sprite1.dispose @sprite2.bitmap.dispose @sprite2.dispose end #-------------------------------------------------------------------------- # ● 释放前景 #-------------------------------------------------------------------------- def dispose_foreground @foreground_sprite.bitmap.dispose @foreground_sprite.dispose end #-------------------------------------------------------------------------- # ● 执行精灵居中 #-------------------------------------------------------------------------- def center_sprite(sprite) sprite.ox = sprite.bitmap.width / 2 sprite.oy = sprite.bitmap.height / 2 sprite.x = Graphics.width / 2 sprite.y = Graphics.height / 2 end #-------------------------------------------------------------------------- # ● 生成指令窗口 #-------------------------------------------------------------------------- def create_command_window @command_window = Window_TitleCommand.new @command_window.set_handler(:new_game, method(:command_new_game)) @command_window.set_handler(:continue, method(:command_continue)) @command_window.set_handler(:shutdown, method(:command_shutdown)) #################################################下面 @command_window.set_handler(:changebgm, method(:command_changebgm_open)) ################################################上面 end #################################################下面 def command_changebgm_open SceneManager.call(Scene_Changebgm) @command_window.close end ##################################################上面 #-------------------------------------------------------------------------- # ● 关闭指令窗口 #-------------------------------------------------------------------------- def close_command_window @command_window.close update until @command_window.close? end #-------------------------------------------------------------------------- # def command_changebgm @changebgm = Bgm_change.new(0,0) end #-------------------------------------------------------------------------- # ● 指令“开始游戏” #-------------------------------------------------------------------------- def command_new_game DataManager.setup_new_game close_command_window fadeout_all $game_map.autoplay SceneManager.goto(Scene_Map) end #-------------------------------------------------------------------------- # ● 指令“继续游戏” #-------------------------------------------------------------------------- def command_continue close_command_window SceneManager.call(Scene_Load) end #-------------------------------------------------------------------------- # ● 指令“退出游戏” #-------------------------------------------------------------------------- def command_shutdown close_command_window fadeout_all SceneManager.exit end #-------------------------------------------------------------------------- # ● 播放标题画面音乐 #-------------------------------------------------------------------------- def play_title_music $data_system.title_bgm.play RPG::BGS.stop RPG::ME.stop end end
def command_changebgm_open SceneManager.call(Scene_Changebgm) @command_window.close end
def command_changebgm_open SceneManager.call(Scene_Changebgm) end
def playbgm bgmname = [ "","Audio/BGM/Theme1","Audio/BGM/Theme2","Audio/BGM/Theme3", "Audio/BGM/Theme4","Audio/BGM/Theme5" ] Audio.bgm_stop filename = bgmname[$NOWBGM] Audio.bgm_play(filename,100,70,0) SceneManager.goto(Scene_Changebgm) end
def savemusic @game_system = Game_System.new @game_system.save_bgm Sound.play_save SceneManager.return end
def savemusic $data_system.title_bgm = bgmname[$NOWBGM] save_data($data_system, "Data/System.rvdata2")
class Scene_Changebgm < Scene_Base #开始处理 def start super @changebgm = Bgm_change.new(0,0) create_background create_command_window @ALLBGMMAX = 5 @NOWBGM = 1 @bgmname = ["","Theme1","Theme2","Theme3","Theme4","Theme5"] end #结束处理 def terminate super @changebgm.dispose dispose_background close_command_window end #生成背景 def create_background @background_sprite = Sprite.new @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(0, 0, 0, 128) end #释放背景 def dispose_background @background_sprite.dispose end #生成窗口指令 def create_command_window @changebgm.set_handler(:biaoti, method(:return_scene)) @changebgm.set_handler(:last, method(:last)) @changebgm.set_handler(:next, method(:next)) @changebgm.set_handler(:savemusic, method(:savemusic)) end #关闭窗口指令 def close_command_window @changebgm.dispose end #上一首 def last if @NOWBGM != 1 @NOWBGM -= 1 elsif @NOWBGM = 1 @NOWBGM = @ALLBGMMAX end playbgm end #下一首 def next if @NOWBGM != @ALLBGMMAX @NOWBGM += 1 elsif @NOWBGM = @ALLBGMMAX @NOWBGM = 1 end playbgm end #播放音乐 def playbgm Audio.bgm_stop Audio.bgm_play("Audio/BGM/#{@bgmname[@NOWBGM]}",100,70,0) end #保存当前音乐 def savemusic $data_system.title_bgm = RPG::BGM.new(@bgmname[@NOWBGM]) save_data($data_system, "Data/System.rvdata2") Sound.play_save return_scene end end
class Bgm_change < Window_Command def initialize(x,y) super self.openness = 0 open end def make_command_list add_command(Vocab::Backbiaoti, :biaoti) add_command(Vocab::Last, :last) add_command(Vocab::Next, :next) add_command(Vocab::Savemusic, :savemusic) end def process_ok super activate end end
#encoding:utf-8 #============================================================================== # ■ Scene_Title #------------------------------------------------------------------------------ # 标题画面 #============================================================================== class Scene_Title < Scene_Base #-------------------------------------------------------------------------- # ● 开始处理 #-------------------------------------------------------------------------- def start super SceneManager.clear Graphics.freeze create_background create_foreground create_command_window play_title_music end #-------------------------------------------------------------------------- # ● 获取渐变速度 #-------------------------------------------------------------------------- def transition_speed return 20 end #-------------------------------------------------------------------------- # ● 结束处理 #-------------------------------------------------------------------------- def terminate super SceneManager.snapshot_for_background dispose_background dispose_foreground end #-------------------------------------------------------------------------- # ● 生成背景 #-------------------------------------------------------------------------- def create_background @sprite1 = Sprite.new @sprite1.bitmap = Cache.title1($data_system.title1_name) @sprite2 = Sprite.new @sprite2.bitmap = Cache.title2($data_system.title2_name) center_sprite(@sprite1) center_sprite(@sprite2) end #-------------------------------------------------------------------------- # ● 生成背景(gai) #-------------------------------------------------------------------------- def create_background beijing = rand(3) case beijing when 0 @beijingtwo = "Book" when 1 @beijingtwo = "Castle" when 2 @beijingtwo = "CrossedSwords" end @sprite1 = Sprite.new @sprite1.bitmap = Cache.title1($data_system.title1_name) @sprite1.bitmap = Cache.title1(@beijingtwo) @sprite2 = Sprite.new @sprite2.bitmap = Cache.title2($data_system.title2_name) center_sprite(@sprite1) center_sprite(@sprite2) end #-------------------------------------------------------------------------- # ● 生成前景 #-------------------------------------------------------------------------- def create_foreground @foreground_sprite = Sprite.new @foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height) @foreground_sprite.z = 100 draw_game_title if $data_system.opt_draw_title end #-------------------------------------------------------------------------- # ● 绘制游戏标题 #-------------------------------------------------------------------------- def draw_game_title @foreground_sprite.bitmap.font.size = 48 rect = Rect.new(0, 0, Graphics.width, Graphics.height / 2) @foreground_sprite.bitmap.draw_text(rect, $data_system.game_title, 1) end #-------------------------------------------------------------------------- # ● 释放背景 #-------------------------------------------------------------------------- def dispose_background @sprite1.bitmap.dispose @sprite1.dispose @sprite2.bitmap.dispose @sprite2.dispose end #-------------------------------------------------------------------------- # ● 释放前景 #-------------------------------------------------------------------------- def dispose_foreground @foreground_sprite.bitmap.dispose @foreground_sprite.dispose end #-------------------------------------------------------------------------- # ● 执行精灵居中 #-------------------------------------------------------------------------- def center_sprite(sprite) sprite.ox = sprite.bitmap.width / 2 sprite.oy = sprite.bitmap.height / 2 sprite.x = Graphics.width / 2 sprite.y = Graphics.height / 2 end #-------------------------------------------------------------------------- # ● 生成指令窗口 #-------------------------------------------------------------------------- def create_command_window @command_window = Window_TitleCommand.new @command_window.set_handler(:new_game, method(:command_new_game)) @command_window.set_handler(:continue, method(:command_continue)) @command_window.set_handler(:shutdown, method(:command_shutdown)) @command_window.set_handler(:changebgm, method(:command_changebgm_open)) end #-------------------------------------------------------------------------- # ● 指令“更改BGM” #-------------------------------------------------------------------------- def command_changebgm_open SceneManager.call(Scene_Changebgm) end #-------------------------------------------------------------------------- # ● 关闭指令窗口 #-------------------------------------------------------------------------- def close_command_window @command_window.close update until @command_window.close? end #-------------------------------------------------------------------------- # ● 指令“开始游戏” #-------------------------------------------------------------------------- def command_new_game DataManager.setup_new_game close_command_window fadeout_all $game_map.autoplay SceneManager.goto(Scene_Map) end #-------------------------------------------------------------------------- # ● 指令“继续游戏” #-------------------------------------------------------------------------- def command_continue close_command_window SceneManager.call(Scene_Load) end #-------------------------------------------------------------------------- # ● 指令“退出游戏” #-------------------------------------------------------------------------- def command_shutdown close_command_window fadeout_all SceneManager.exit end #-------------------------------------------------------------------------- # ● 播放标题画面音乐 #-------------------------------------------------------------------------- def play_title_music $data_system.title_bgm.play RPG::BGS.stop RPG::ME.stop end end
#encoding:utf-8 #============================================================================== # ■ Window_TitleCommand #------------------------------------------------------------------------------ # 标题画面中,选择“开始游戏/继续游戏”的窗口。 #============================================================================== class Window_TitleCommand < Window_Command #-------------------------------------------------------------------------- # ● 初始化对象 #-------------------------------------------------------------------------- def initialize super(0, 0) update_placement select_symbol(:continue) if continue_enabled self.openness = 0 open end #-------------------------------------------------------------------------- # ● 获取窗口的宽度 #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # ● 更新窗口的位置 #-------------------------------------------------------------------------- def update_placement self.x = (Graphics.width - width) / 2 self.y = (Graphics.height * 1.6 - height) / 2 end #-------------------------------------------------------------------------- # ● 生成指令列表 #-------------------------------------------------------------------------- def make_command_list add_command(Vocab::new_game, :new_game) add_command(Vocab::continue, :continue, continue_enabled) add_command(Vocab::Changebgm,:changebgm) add_command(Vocab::shutdown, :shutdown) end #-------------------------------------------------------------------------- # ● 获取“继续游戏”选项是否有效 #-------------------------------------------------------------------------- def continue_enabled DataManager.save_file_exists? end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |