Splash Screen

0 Members and 1 Guest are viewing this topic.

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Splash Screen
Version: 1.0
Author: TDS
Date: 04 16, 2012

Version History


  • 1.0 2012.04.16 - Public Release

Description


This script allows you to display images before the the title screen is shown.

Features

  • Show pictures before the title screen appears.
  • Play sounds along with the pictures.

Instructions

Instructions are on the script.

Script


Code: [Select]
#==============================================================================
# ** TDS Splash Screen
#    Ver: 1.0
#------------------------------------------------------------------------------
#  * Description:
#  This script allows you to display images before the the title screen is shown.
#------------------------------------------------------------------------------
#  * Features:
#  Show pictures before the title screen appears.
#  Play sounds along with the pictures.
#------------------------------------------------------------------------------
#  * Instructions:
#  To set the settings of a splash image edit the constant "SPLASH_SETTINGS".
#
#  SPLASH_SETTINGS = {
#  Index => {Symbol Settings},
#  Index => {Symbol Settings},
#  Index => {Symbol Settings},
#  }
#
#  Splash Settings Symbols. (Requires knowledge of hashes and arrays)
#
#  Required:
#   :name => "Picture Name"
#   :fadein => Splash Fade in duration. (0 for instant)
#   :fadeout => Splash Fade out duration. (0 for instant)
#   :duration => Pause Duration. (1.0 / 0 for infinite pause until input skips it)
#
#  Optional:
#   :skippable => Flag for making pause duratio skippable True/False. (Required if pause is infinite)
#   :centered => Centers Picture based on screen size.
#   :start_SE => SE That will play after fade in. (["SE Name", Volume, Pitch])
#   :start_ME => ME That will play after fade in. (["ME Name", Volume, Pitch])
#   :end_wait => Pause duration after fadeout before the next image is shown.
#
#  Example:
#
#  Single Splash Image (Simple Fade in and Fade out with infinite duration)
#
#  SPLASH_SETTINGS = {
#  1 => {:name => "Name", :fadein => 20, :fadeout => 20, :duration => 1.0 / 0,
#        :skippable => true, :centered => true, :start_SE => ["Wolf", 100, 80],
#        :end_wait => 40},
#  }
#
#  To make it so whenever you restart the game it shows the splash pictures
#  again set this constant to true. (It's false by default)

#  RETURN_SPLASH_SHOW = true
#
#  To make it so it will show the splash screens while testing, set this
#  constant to true (False by default).
#
#  SHOW_ON_PLAYTEST = false
#------------------------------------------------------------------------------
#  * Notes:
#  None.
#------------------------------------------------------------------------------
# WARNING:
#
# Do not release, distribute or change my work without my expressed written
# consent, doing so violates the terms of use of this work.
#
# If you really want to share my work please just post a link to the original
# site.
#
# * Not Knowing English or understanding these terms will not excuse you in any
#   way from the consequenses.
#==============================================================================
# * Import to Global Hash *
#==============================================================================
($imported ||= {})[:TDS_Splash_Screen] = true

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs the title screen processing.
#==============================================================================

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  # Splash Settings Hash
  SPLASH_SETTINGS = {
  # First Splash Image (Simple Fade in and Fade out with infinite duration)
  1 => {:name => "Splash1", :fadein => 20, :fadeout => 20, :duration => 1.0 / 0,
        :skippable => true, :centered => true, :start_SE => ["Wolf", 100, 80],
        :end_wait => 40},

  # Second Splash Image (Sound with Fade in and Fade out with limited duration)
  2 => {:name => "Splash2", :fadein => 20, :fadeout => 20, :duration => 300,
        :skippable => false, :centered => true, :start_ME => ["Gag", 100, 80]} 
  }
  # Show Flash when returning to the title from the game
  RETURN_SPLASH_SHOW = false
  # Show on Play Test
  SHOW_ON_PLAYTEST = false
  #--------------------------------------------------------------------------
  # * Alias Listings
  #-------------------------------------------------------------------------- 
  alias tds_splash_screen_scene_title_initialize                   initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize   
    # Start Splash Intro
    start_splash_intro   
    # Run Original Method
    tds_splash_screen_scene_title_initialize
  end 
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start_splash_intro
    # Return if Show on Play Test is false
    return if $TEST and !SHOW_ON_PLAYTEST
    # Fadeout Screen
    Graphics.fadeout(0)   
    # Dispose of SceneManager Background Bitmap if it's not nil
    SceneManager.background_bitmap.dispose if !SceneManager.background_bitmap.nil?
    # Return if Return Flash Show is false and Stack is not empty
    return if !RETURN_SPLASH_SHOW and !SceneManager.instance_variable_get(:@stack).empty?   
    # Display Splash Images
    SPLASH_SETTINGS.keys.sort.each {|i| display_splash_image(SPLASH_SETTINGS[i])}
  end
  #--------------------------------------------------------------------------
  # * Display Splash Image
  #     settings : splash image settings
  #--------------------------------------------------------------------------
  def display_splash_image(settings)
    # Return if settings are nil
    return if settings.nil?
    # Make Splash Image Sprite
    @splash_image = Sprite.new
    # Make Splash Image Bitmap
    @splash_image.bitmap = Cache.picture(settings[:name])
    # Center Sprite if Applicable
    center_sprite(@splash_image) if settings[:centered]
    # Fade In
    Graphics.fadein(settings[:fadein])   
    # If Start SE
    if settings[:start_SE]
      # Sound Effect Args
      se_args = settings[:start_SE].dup
      # Add Folder Location to SE Name
      se_args[0] = 'Audio/SE/' + settings[:start_SE][0]
      # Play SE if Applicable
      Audio.se_play(*se_args)       
    end
   
    # If Start ME
    if settings[:start_ME]
      # Sound Effect Args
      me_args = settings[:start_ME].dup
      # Add Folder Location to SE Name
      me_args[0] = 'Audio/ME/' + settings[:start_ME][0]
      # Play SE if Applicable
      Audio.me_play(*me_args)       
    end   
   
    # If Duration is Infinite
    if settings[:duration].is_a?(Float) and settings[:duration].infinite?     
      # Duration Wait
      loop do
        # Update Basic Components
        update_basic
        # Break if Input Trigger C or B
        break if Input.trigger?(:C) or Input.trigger?(:B)
      end
    else
      # Duration Wait
      settings[:duration].times do
        # Update Basic Components
        update_basic
        # Break if Skippable and Input Trigger C or B
        break if settings[:skippable] and Input.trigger?(:C) or Input.trigger?(:B)
      end
    end   
    # Fadeout
    Graphics.fadeout(settings[:fadeout])
    # After Splash Image Display Delay
    settings[:end_wait].times do update_basic end if settings[:end_wait]
    # Stop SE and ME sounds
    RPG::SE.stop ; RPG::ME.stop
    # Dispose of Splash Image
    @splash_image.dispose ; @splash_image = nil
  end
end


Credit


  • TDS


Support


On this topic.

Known Compatibility Issues

None that I'm aware of so far.

Terms of Use

Only for use in non-commercial games.