Introduction & Splash System

8 de março de 2013

Este script foi desenvolvido por SephirothSpawn para você criar uma introdução antes da tela de título, num projeto de RPG Maker XP.

Você terá, também, a opção para mostrar uma splash screen, onde uma imagem ira piscar (geralmente com um “Press Start“). Também adiciona um timer tanto na splash screen e na tela de título, para que, depois de X segundos, vai fazer um replay da introdução e da splash. Esta, sendo opcional, não será mostrada no editor (Debug Mode).

Introdução

Adicione o script abaixo do SDK e acima do Main. Para configurar a introdução, veja os comentários no código abaixo:

#==============================================================================
# ** Introduction & Splash System
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 3
# 2006-03-04
#------------------------------------------------------------------------------
# * Description :
#
#   This Script was designed to create an introduction before the title screen
#   in your game. You will also have the option to display a splash screen,
#   where an image will flash (Usually Press Start). It also adds a timer at
#   both the splash screen and in the title screen, so after X seconds, it
#   will replay the introduction and splash. The splash is completely
#   optional. It will not be displayed from the editor (Debug Mode).
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   To Setup Introduction, refer to customization below.
#------------------------------------------------------------------------------
# * Customization :
#
#   Setting Up Introduction Pictures
#    - Intro_Pictures = ['Pic 1', ...]
#
#   Setting Up Splash Pictures
#    - Splash = 'filename' or nil
#
#   (Pictures Should Be in the Titles Folder)
#
#   Picture Fade In Speed
#    - Picture_Fade_Speed = X
#
#   Splash Button Speed
#    - Start_Fade_Speed = X
#
#   Seconds Until Introduction Leaves Splash & Title
#    - Seconds_Until_Restart = X
#
#   Intorudction BGM
#    - Introduction_BGM = RPG::AudioFile
#
#   Restart Introduction At Splash Flag
#    - Restart_At_Splash = true (RESTART) or false (DON'T RESTART)
#
#   Restart Introduction At Title Flag
#    - Restart_At_Title = true (RESTART) or false (DON'T RESTART)
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Introduction & Splash System', 'SephirothSpawn', 2.1, '2006-03-04')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Introduction & Splash System') == true

#==============================================================================
# ** Scene_Introduction
#==============================================================================

class Scene_Introduction
  #--------------------------------------------------------------------------
  # * Options
  #--------------------------------------------------------------------------
  Intro_Pictures = ['001-Title01', '001-Title01']
  Splash = nil
  Picture_Fade_Speed = 5
  Start_Fade_Speed = 5
  Seconds_Until_Restart = 5
  Introduction_BGM = load_data('Data/System.rxdata').title_bgm
  Restart_At_Splash = true
  Restart_At_Title = true
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Instance Variables      
    @index, @phase = 0, 0
    @speed, @s_speed = Picture_Fade_Speed, Start_Fade_Speed
    # Background Images
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.title(Intro_Pictures[@index])
    @sprite.opacity = 5
    # Start Logo
    unless Splash.nil?
      @start = Sprite.new
      @start.bitmap = RPG::Cache.title('Start')
      @start.x = 320 - @start.bitmap.width / 2
      @start.y = 480 - @start.bitmap.height - 32
      @start.z, @start.opacity = 10, 0
    end
    # Play Introduction BGM
    Audio.bgm_play('Audio/BGM/' + Introduction_BGM.name)
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose Sprites
    @sprite.dispose
    @start.dispose unless @start.nil?
    # Fade BGM
    Audio.bgm_fade(5)
    # If Premain
    $pre_main ? $pre_main = false : $scene = Scene_Title.new
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    case @phase
    when 0 # Introduction Procreesing
      update_intro
    when 1 # Splash Procreesing
      update_splash
    when 2 # Splash Transition
      to_splash_transition
    when 3 # Title Transition
      to_title_transition
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Intro Images
  #--------------------------------------------------------------------------
  def update_intro
    # If C is pressed
    if Input.trigger?(Input::C)
      @speed *= -1 if @speed > 0
      @phase = Splash.nil? ? 3 : 2
    end
    # Updates Sprite Opacity
    @sprite.opacity += @speed
    # Changes Direction
    @speed *= -1 if @sprite.opacity >= 255
    # Change Sprite
    if @sprite.opacity <= 0
      @index += 1 ; @speed *= -1
      @index == Intro_Pictures.size ? @phase = Splash.nil? ? 3 : 2 :
        @sprite.bitmap = RPG::Cache.title(Intro_Pictures[@index])
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Splash Image
  #--------------------------------------------------------------------------
  def update_splash
    # If Restart on splash and seconds reached
    if Restart_At_Splash && Graphics.frame_count % 
      (Graphics.frame_rate * Seconds_Until_Restart) == 0
      # Restart Scene
      $scene = self.new(Intro_Pictures, Splash)
      return
    end
    # If C is pressed
    if Input.trigger?(Input::C)
      @speed *= -1 if @speed > 0
      @s_speed *= -1 if @s_speed > 0
      @phase = 3
    end
    # Loads Sprite Splash Bitmap
    @sprite.bitmap = RPG::Cache.title(Splash)
    # Updates Start Logo Opacity
    @start.opacity += @s_speed
    # Changes Direction
    @s_speed *= -1 if @start.opacity >= 255 || @start.opacity <= 0
    # Updates Splash
    @sprite.opacity += @speed if @sprite.opacity < 255
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Intro To Splash Transistion
  #--------------------------------------------------------------------------
  def to_splash_transition
    @sprite.opacity > 0 ? @sprite.opacity += @speed : @phase = 1
  end
  #--------------------------------------------------------------------------
  # * Frame Update : Splash To Title Transistion
  #--------------------------------------------------------------------------
  def to_title_transition
    # Decrease Splash Opacity
    @sprite.opacity += @speed if @sprite.opacity > 0
    # Decresh Start Logo Opacity
    unless @start.nil?
      @start.opacity += @s_speed if @start.opacity > 0
    end
    # Proceed to Title Screen
    return if @sprite.opacity > 0
    unless @start.nil?
      return if @start.opacity > 0
    end
    # End Introduction
    $scene = nil
    # Restart Graphics Frame Count
    Graphics.frame_count = 0
  end
end

#==============================================================================
# ** Scene_Title
#==============================================================================

class Scene_Title
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_intro_scnttl_update update
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # If Not Debug
    unless $DEBUG
      # If Restart && Seconds Reached
      if Scene_Introduction::Restart_At_Splash && Graphics.frame_count % 
        (Graphics.frame_rate * Scene_Introduction::Seconds_Until_Restart) == 0
        # Switch to Splash Scene
        $scene = Scene_Introduction.new
      end
    end
    # Original Update
    seph_intro_scnttl_update
  end
end

#==============================================================================
# ** Pre-Main
#------------------------------------------------------------------------------
#  After defining each class, actual processing begins here.
#==============================================================================

unless $DEBUG
  begin 
    # Sets Pre-main flag
    $pre_main = true
    # Prepare for transition
    Graphics.freeze
    # Proceed to Introduction & Splash Scene
    $scene = Scene_Introduction.new
    # Call main method as long as $scene is effective
    while $scene != nil
      $scene.main
    end
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!