Advertisement
Zerbu

RPG Maker VX Ace - Text Sound Effect v2

Dec 31st, 2011
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.74 KB | None | 0 0
  1. #==============================================================================
  2. # Text Sound Effect (version 2)
  3. # NEW FEATURE: Switch to turn off sound effect
  4. #------------------------------------------------------------------------------
  5. # by Zerbu
  6. #==============================================================================
  7. module Text_Sound_Effect
  8.   #--------------------------------------------------------------------------
  9.   # Options
  10.   #--------------------------------------------------------------------------
  11.   # The sound effect to play
  12.   MESSAGE_SOUND = RPG::SE.new("Knock", 70, 80)
  13.  
  14.   # The number of characters to display before each time the sound plays
  15.   # The default is 3, it's recommended you keep it as this unless you
  16.   # know what you're doing
  17.   MESSAGE_SOUND_FRAMES = 3
  18.  
  19.   # Switch to disable sound effect
  20.   # If you need to turn off the sound effect for any part of the game,
  21.   # turn this switch on
  22.   MESSAGE_SOUND_DISABLE = 2
  23.  
  24. end
  25.  
  26. class Window_Base < Window
  27.   include Text_Sound_Effect
  28.   #--------------------------------------------------------------------------
  29.   # alias method: process_characer
  30.   #--------------------------------------------------------------------------
  31.   alias textsound_process_character_normal process_character
  32.   def process_character(c, text, pos)
  33.     if !$game_switches[MESSAGE_SOUND_DISABLE]
  34.       #---
  35.       if !defined?(@sound_frames)
  36.         @sound_frames = 0
  37.       end
  38.       #---
  39.       if @sound_frames == 0
  40.         MESSAGE_SOUND.play
  41.       end
  42.       #---
  43.       @sound_frames+=1
  44.       #---
  45.       if @sound_frames == MESSAGE_SOUND_FRAMES
  46.         @sound_frames = 0
  47.       end
  48.       #---
  49.     end
  50.     textsound_process_character_normal(c, text, pos)
  51.   end
  52.   #---
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement