Advertisement
Zerbu

RPG Maker VX Ace - Text Sound Effect

Dec 31st, 2011
461
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.44 KB | None | 0 0
  1. #==============================================================================
  2. # Text Sound Effect
  3. #------------------------------------------------------------------------------
  4. # by Zerbu
  5. #==============================================================================
  6. module Text_Sound_Effect
  7.  
  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. end
  19.  
  20. class Window_Base < Window
  21.   include Text_Sound_Effect
  22.   #--------------------------------------------------------------------------
  23.   # alias method: process_characer
  24.   #--------------------------------------------------------------------------
  25.   alias textsound_process_character_normal process_character
  26.   def process_character(c, text, pos)
  27.     #---
  28.     if !defined?(@sound_frames)
  29.       @sound_frames = 0
  30.     end
  31.     #---
  32.     if @sound_frames == 0
  33.       MESSAGE_SOUND.play
  34.     end
  35.     #---
  36.     @sound_frames+=1
  37.     #---
  38.     if @sound_frames == MESSAGE_SOUND_FRAMES
  39.       @sound_frames = 0
  40.     end
  41.     #---
  42.     textsound_process_character_normal(c, text, pos)
  43.     #---
  44.   end
  45.   #---
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement