Guest User

Untitled

a guest
Dec 17th, 2013
441
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2. Fade In BGM
  3. by Fomar0153
  4. Version 1.0
  5. ----------------------
  6. Notes
  7. ----------------------
  8. Allows you to fade in BGM.
  9. ----------------------
  10. Instructions
  11. ----------------------
  12. First play the BGM you want to fade in.
  13. Then use a script call:
  14. bgm_fadein(frames,volume)
  15. e.g.
  16. bgm_fadein(120,100)
  17. at 60 frames per second that would fade in the music to 100% volume over 2 seconds.
  18. ----------------------
  19. Known bugs
  20. ----------------------
  21. None
  22. =end
  23.  
  24. class Game_Interpreter
  25.   #--------------------------------------------------------------------------
  26.   # * Public Instance Variables
  27.   #--------------------------------------------------------------------------
  28.   def bgm_fadein(frames,volume)
  29.     SceneManager.scene.bgm_fadein(frames,volume)
  30.   end
  31. end
  32.  
  33. class Scene_Base
  34.   #--------------------------------------------------------------------------
  35.   # * Public Instance Variables
  36.   #--------------------------------------------------------------------------
  37.   def bgm_fadein(frames,volume)
  38.     @fadein = RPG::BGM.last
  39.     RPG::BGM.fade(0)
  40.     @t = 1
  41.     @volume = volume
  42.     @frames = frames
  43.   end
  44.   #--------------------------------------------------------------------------
  45.   # * Update Frame (Basic)
  46.   #--------------------------------------------------------------------------
  47.   alias fadein_update_basic update_basic
  48.   def update_basic
  49.     fadein_update_basic
  50.     if @fadein != nil
  51.       @fadein.volume = (@volume * ((@t) / @frames.to_f)).to_i
  52.       @t += 1
  53.       @fadein.play
  54.       if @fadein.volume == @volume
  55.         @fadein = nil
  56.         @volume = nil
  57.         @t = nil
  58.         @frames = nil
  59.       end
  60.     end
  61.   end
  62. end
RAW Paste Data