Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # Dragon Scene Title
- # Autor: King Gerar
- #-------------------------------------------------------------------------------
- # Tela de título (Scene_Title) modificada, com a função "Press Start" e uma
- # barrinha de "Loading". Todas as animações são compostas por imagens, portanto
- # fique atento.
- #===============================================================================
- # O módulo Title_Images guarda as imagens que serão usadas no Scene Title.
- # Essas imagens devem estar na pasta Graphics/System de seu projeto.
- #===============================================================================
- module Title_Images
- TitleBackground = "Title-Background"
- TitleName = "Title-NameTitle"
- TitlePressStart = "Title-PressStart"
- TitleNewGame = "Title-NewGame"
- TitleContinue = "Title-Continue"
- TitleQuit = "Title-Quit"
- TitleLoadingBorder = "Title-LoadGameBox"
- TitleLoadingBar = "Title-LoadBar"
- end
- #===============================================================================
- # Modificações erradas abaixo pode provocar o mal ou o não funcionamento do
- # script.
- #===============================================================================
- class Scene_Title < Scene_Base
- include Title_Images
- #-----------------------------------------------------------------------------
- # Criação do Background.
- #-----------------------------------------------------------------------------
- def create_background
- @background = Sprite.new
- @background.bitmap = Cache.system(TitleBackground)
- center_sprite(@background)
- @background.z = 1
- end
- def dispose_background
- @background.bitmap.dispose
- @background.dispose
- end
- #-----------------------------------------------------------------------------
- # Criação das imagens de Press Start.
- #-----------------------------------------------------------------------------
- def create_press_start
- @press_start = Sprite.new
- @press_start.bitmap = Cache.system(TitlePressStart)
- center_sprite(@press_start)
- @press_start.z = 100
- @press_start2 = Sprite.new
- @press_start2.bitmap = Cache.system(TitlePressStart)
- center_sprite(@press_start2)
- @press_start2.z = 101
- @press_start2.visible = false
- end
- def dispose_press_start
- @press_start.bitmap.dispose
- @press_start.dispose
- end
- def dispose_press_start2
- @press_start2.bitmap.dispose
- @press_start2.dispose
- end
- #-----------------------------------------------------------------------------
- # Criação da imagem do Nome/Logo.
- #-----------------------------------------------------------------------------
- def create_name_project
- @name_project = Sprite.new
- @name_project.bitmap = Cache.system(TitleName)
- center_sprite(@name_project)
- @name_project.opacity = 0
- @name_project.z = 200
- end
- def dispose_name_project
- @name_project.bitmap.dispose
- @name_project.dispose
- end
- #-----------------------------------------------------------------------------
- # Criação da imagem das Opções.
- #-----------------------------------------------------------------------------
- def create_options_img
- @options_img = Sprite.new
- @options_img2 = Sprite.new
- if continue_enabled
- @options_img.bitmap = Cache.system(TitleContinue)
- @options_img2.bitmap = Cache.system(TitleContinue)
- else
- @options_img.bitmap = Cache.system(TitleNewGame)
- @options_img2.bitmap = Cache.system(TitleNewGame)
- end
- @options_img.x += 125
- @options_img.y = 0
- @options_img.opacity = 0
- @options_img.z = 250
- @options_img2.x -= 125
- @options_img2.y = 0
- @options_img2.opacity = 0
- @options_img2.z = 251
- end
- def dispose_options_img
- @options_img.bitmap.dispose
- @options_img.dispose
- end
- def dispose_options_img2
- @options_img2.bitmap.dispose
- @options_img2.dispose
- end
- #-----------------------------------------------------------------------------
- # Barra de Loading.
- #-----------------------------------------------------------------------------
- def create_loading_box
- @loading_box = Sprite.new
- @loading_box.bitmap = Cache.system(TitleLoadingBorder)
- center_sprite(@loading_box)
- @loading_box.opacity = 0
- @loading_box.z = 200
- end
- def create_loading_bar
- @loading_bar = Sprite.new
- @loading_bar.bitmap = Cache.system(TitleLoadingBar)
- @loading_bar.opacity = 0
- @loading_bar.x = 24
- @loading_bar.y = 361
- @loading_bar.zoom_x = 0.00
- @size_bar1 = 0.00
- @size_bar2 = 200.00
- @size_bar_final = 0.00
- @loading_bar.z = 100
- end
- def dispose_loading_box
- @loading_box.bitmap.dispose
- @loading_box.dispose
- end
- def dispose_loading_bar
- @loading_bar.bitmap.dispose
- @loading_bar.dispose
- end
- #-----------------------------------------------------------------------------
- # Inicialização do processo da Scene Title.
- #-----------------------------------------------------------------------------
- def start
- super
- @press_button = false
- @press_button_move = false
- @eneabled_options = false
- @show_name_project = false
- @change_options = false
- @loading = false
- SceneManager.clear
- Graphics.freeze
- create_background
- create_press_start
- create_name_project
- create_options_img
- create_loading_box
- create_loading_bar
- create_command_window
- play_title_music
- end
- def update
- super
- @press_start.visible = false if Graphics.frame_count % 18 == 0 && @press_button == false
- @press_start.visible = true if Graphics.frame_count % 36 == 0 && @press_button == false
- if @press_button == false
- if Input.trigger?(:C)
- Sound.play_ok
- @press_button = true
- @press_button_move = true
- @press_start2.visible = true
- @press_start2.opacity = 255
- end
- end
- if @press_button_move == true
- if @press_start.x <= 400
- @press_start.x += 4
- @press_start.opacity -= 15
- @press_start2.x -= 4
- @press_start2.opacity -= 15
- else
- @press_start.visible = false
- @press_start2.visible = false
- @press_button_move = false
- @show_name_project = true
- end
- end
- if @show_name_project == true
- if @name_project.opacity < 255
- @name_project.opacity += 5
- else
- @eneabled_options = true
- @show_name_project = false
- end
- end
- if @eneabled_options == true
- if @options_img.x >= 0
- @options_img.x -= 5
- @options_img.opacity += 10
- @options_img2.x += 5
- @options_img2.opacity += 10
- else
- @options_img.x = 0
- @options_img2.visible = false
- @command_window.visible = true
- @command_window.activate
- @change_options = true
- @eneabled_options = false
- end
- end
- if @change_options == true
- if @command_window.index == 0
- @options_img.bitmap = Cache.system(TitleNewGame)
- end
- if @command_window.index == 1
- @options_img.bitmap = Cache.system(TitleContinue)
- end
- if @command_window.index == 2
- @options_img.bitmap = Cache.system(TitleQuit)
- end
- end
- if @loading == true
- if @name_project.opacity > 0
- @name_project.opacity -= 5
- @options_img.opacity -= 5
- else
- if @loading_box.opacity < 255
- @loading_box.opacity += 15
- else
- @loading_bar.opacity = 255
- if @size_bar_final <= 1.00
- @size_bar1 += 1.00
- @size_bar_final = @size_bar1 / @size_bar2
- @loading_bar.zoom_x = @size_bar_final
- else
- DataManager.setup_new_game
- fadeout_all
- $game_map.autoplay
- SceneManager.goto(Scene_Map)
- end
- end
- end
- end
- end
- #-----------------------------------------------------------------------------
- # Aquisição da velocidade de transição
- #-----------------------------------------------------------------------------
- def transition_speed
- return 60
- end
- #-----------------------------------------------------------------------------
- # Finalização do processo
- #-----------------------------------------------------------------------------
- def terminate
- super
- SceneManager.snapshot_for_background
- dispose_background
- dispose_press_start
- dispose_press_start2
- dispose_name_project
- dispose_options_img
- dispose_options_img2
- dispose_loading_box
- dispose_loading_bar
- end
- #-----------------------------------------------------------------------------
- # Movimento do sprite para o meio da tela
- # sprite : sprite a ser movido
- #-----------------------------------------------------------------------------
- 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
- #-----------------------------------------------------------------------------
- # Criação da janela de comando
- #-----------------------------------------------------------------------------
- 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.deactivate
- @command_window.opacity = 0
- @command_window.contents_opacity = 0
- @command_window.visible = false
- end
- #-----------------------------------------------------------------------------
- # Fechamento da janela de comando
- #-----------------------------------------------------------------------------
- def close_command_window
- @command_window.close
- update until @command_window.close?
- end
- #-----------------------------------------------------------------------------
- # Comando [Novo Jogo]
- #-----------------------------------------------------------------------------
- def command_new_game
- @loading = true
- close_command_window
- # DataManager.setup_new_game
- # fadeout_all
- # $game_map.autoplay
- # SceneManager.goto(Scene_Map)
- end
- #-----------------------------------------------------------------------------
- # Comando [Continuar]
- #-----------------------------------------------------------------------------
- def command_continue
- close_command_window
- SceneManager.call(Scene_Load)
- end
- #-----------------------------------------------------------------------------
- # Comando [Sair]
- #-----------------------------------------------------------------------------
- def command_shutdown
- close_command_window
- fadeout_all
- SceneManager.exit
- end
- #-----------------------------------------------------------------------------
- # Executar música de título
- #-----------------------------------------------------------------------------
- def play_title_music
- $data_system.title_bgm.play
- RPG::BGS.stop
- RPG::ME.stop
- end
- #-----------------------------------------------------------------------------
- # Aquisição do estado de habilitação de continuação
- #-----------------------------------------------------------------------------
- def continue_enabled
- DataManager.save_file_exists?
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement