Advertisement
Zerbu

RPG Maker VX Ace - Text Sound Effect

Dec 31st, 2011
113
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.   # Options
  9.   #--------------------------------------------------------------------------
  10.   # The sound effect to play
  11.   MESSAGE_SOUND = RPG::SE.new("Knock", 70, 80)
  12.  
  13.   # The number of characters to display before each time the sound plays
  14.   # The default is 3, it's recommended you keep it as this unless you
  15.   # know what you're doing
  16.   MESSAGE_SOUND_FRAMES = 3
  17. end
  18.  
  19. class Window_Base < Window
  20.   include Text_Sound_Effect
  21.   #--------------------------------------------------------------------------
  22.   # alias method: process_characer
  23.   #--------------------------------------------------------------------------
  24.   alias textsound_process_character_normal process_character
  25.   def process_character(c, text, pos)
  26.     #---
  27.     if !defined?(@sound_frames)
  28.       @sound_frames = 0
  29.     end
  30.     #---
  31.     if @sound_frames == 0
  32.       MESSAGE_SOUND.play
  33.     end
  34.     #---
  35.     @sound_frames+=1
  36.     #---
  37.     if @sound_frames == MESSAGE_SOUND_FRAMES
  38.       @sound_frames = 0
  39.     end
  40.     #---
  41.     textsound_process_character_normal(c, text, pos)
  42.     #---
  43.   end
  44.   #---
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement