Jump to content
Vincent

Basic Pause Screen

Recommended Posts

This adds the ability to call a basic pause screen when pressing a button. Further options allow for a picture to replace pause text and BGM for the pause screen. What separates this from the command menu is that it can be called in the middle of an event in case the player has any urgency outside of the game.

 

Script

 

 

#==============================================================================
# ** Pause Screen
# By Vincent
#------------------------------------------------------------------------------
# Adds a pause screen for when the player presses a certain button. NOTE: The
# pause screen can be opened in the middle of in-game events. This is
# intentional, as a pause screen exists as an emergency way to postpone
# gameplay urgently without throwing away progress.
#
# Versions:
#
# *October 15, 2014 - First release. Added picture and BGM options.
# October 14, 2014  - First version.
#==============================================================================
# TODO: Find a way to keep map BGM but at a lower volume. Make the pause screen
# able to appear in battle without showing the map.

PAUSETEXT       = "Paused"      #Text on pause screen.
PAUSEWIDTH      = 94            #Width of invisible pause window.
PAUSEBUTTON     = :CTRL         #Button for calling pause screen.
PAUSEBGM        = "Dungeon2"    #BGM to play on pause screen. "" is silence.
PAUSEVOL        = 65            #Volume of BGM on pause screen.
PAUSEPITCH      = 85            #Pitch of BGM on pause screen.

USE_PAUSE_IMAGE = false         #If you want to use a pic, set to true.
PAUSE_PIC       = "Pause"       #Picture's name in the Graphics/Pictures folder.
PAUSEPIC_HEIGHT = 75            #Picture's height for dimension correction.

#==============================================================================
# ** Window_Pause
#------------------------------------------------------------------------------
#  Pause text.
#==============================================================================

class Window_Pause < Window_Command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0)
    update_placement
    self.openness = 0
    self.opacity = 0
    open
  end
  
  if USE_PAUSE_IMAGE
    alias pause_pic_up update
    def update
      pause_pic_up
      self.contents = Cache.picture(PAUSE_PIC)
    end
  end
  #--------------------------------------------------------------------------
  # * Get Line Height
  #--------------------------------------------------------------------------
  if USE_PAUSE_IMAGE
    alias pause_pic_height line_height
    def line_height
      pause_pic_height
      return PAUSEPIC_HEIGHT
    end
  end  
  #--------------------------------------------------------------------------
  # * Window Placement
  #--------------------------------------------------------------------------
  def update_placement
    self.x = (Graphics.width - width) / 2
    self.y = (Graphics.height - height) / 2
  end
  #--------------------------------------------------------------------------
  # * Get Window Width
  #--------------------------------------------------------------------------
  def window_width
    return PAUSEWIDTH
  end
  #--------------------------------------------------------------------------
  # * Create Command List
  #--------------------------------------------------------------------------
  def make_command_list
    add_pause_command
  end
  #--------------------------------------------------------------------------
  # * Processing When OK Button Is Pressed
  #--------------------------------------------------------------------------
  def process_ok
    #Nothing happens at all! This keeps the player from being able to spam the
    #button to make the pause window flash and make a "confirm" sound.
  end
  #--------------------------------------------------------------------------
  # * Add Main Commands to List
  #--------------------------------------------------------------------------
  def add_pause_command
    add_command(PAUSETEXT,   :pause)
  end
end

class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # * Aliased Start Processing
  #--------------------------------------------------------------------------
  alias pause_map_start start
  def start
    pause_map_start
    update_call_pause
  end
  #--------------------------------------------------------------------------
  # * Aliased update method
  #--------------------------------------------------------------------------
  alias pause_update update
  def update
    pause_update
    update_call_pause
  end
  #--------------------------------------------------------------------------
  # * Determine if Pause Call by custom key
  #--------------------------------------------------------------------------
  def update_call_pause
    SceneManager.call(Scene_Pause) if Input.press?(PAUSEBUTTON)
  end
end

#==============================================================================
# ** Scene_Pause
#------------------------------------------------------------------------------
#  Shows the window and pretty much does nothing else.
#==============================================================================

class Scene_Pause < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Start Processing
  #--------------------------------------------------------------------------
  def start
    super
     pause_save_bgm_and_bgs
     RPG::BGS.stop
     RPG::BGM.new(PAUSEBGM, PAUSEVOL, PAUSEPITCH).play
    create_pause_window
  end
  #--------------------------------------------------------------------------
  # * Volume stuff
  #--------------------------------------------------------------------------
  def pause_save_bgm_and_bgs
    @paused_map_bgm = RPG::BGM.last
    @paused_map_bgs = RPG::BGS.last
  end  
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_pause_window
    @command_window = Window_Pause.new
    @command_window.set_handler(PAUSETEXT,      method(:pausetxt))
    @command_window.set_handler(:cancel,    method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # * [Item] Command
  #--------------------------------------------------------------------------
  def pausetxt
  end
  #--------------------------------------------------------------------------
  # * Return to Calling Scene
  #--------------------------------------------------------------------------
  def return_scene
    super
    @paused_map_bgm.play
    @paused_map_bgs.play
  end
end

 

 

 

Screenshots

Screenshot2014-10-15150720.png

 

Screenshot2014-10-15150823.png

 

Instructions

Just paste it into the materials section. If a custom image is used, you will need to place the image in Graphics/Pictures and customize the appopriate settings in the script.

 

Known issues

No "issues" per se, but the pause screen cannot be called in battle without  showing the overworld map. I will find a workaround once I get more scripting experience.

 

Credits

Me, but you don't need to credit me or anything

Edited by Vincent

Share this post


Link to post
Share on other sites

This is actually a good idea. There are many people who make games that don't require a menu at all and to make a pause screen through events is a little bit of a hassle.

 

Good work!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted