mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 21:39:57 +00:00
Added fadein functionality for bgm
This lets the user fadein bgm after using a normal "play bgm" command in the event editor. Just simply call "Script.fadein_bgm(target, speed)" with the target being the target vol % that you want the fade in to eventually reach and the speed being how fast you want it to reach it (1 - slowest, 100-instant)
This commit is contained in:
parent
da01da31e7
commit
77fdd558cb
4 changed files with 29 additions and 0 deletions
|
|
@ -20,6 +20,7 @@ class Game_System
|
|||
attr_accessor :message_frame # text option: window frame
|
||||
attr_accessor :save_count # save count
|
||||
attr_accessor :magic_number # magic number
|
||||
attr_accessor :playing_bgm
|
||||
#--------------------------------------------------------------------------
|
||||
# * Object Initialization
|
||||
#--------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ class Game_Temp
|
|||
#--------------------------------------------------------------------------
|
||||
# * Public Instance Variables
|
||||
#--------------------------------------------------------------------------
|
||||
attr_accessor :target_bgm_vol_level # volume we want to reach when fading in music
|
||||
attr_accessor :bgm_fadein_speed # speed at which we will reach target bgm vol_level
|
||||
attr_accessor :bgm_fadein_timer # used so we aren't changing the volume every frame
|
||||
attr_accessor :map_bgm # map music (for battle memory)
|
||||
attr_accessor :message_text # message text
|
||||
attr_accessor :message_face # face graphic
|
||||
|
|
@ -62,6 +65,9 @@ class Game_Temp
|
|||
# * Object Initialization
|
||||
#--------------------------------------------------------------------------
|
||||
def initialize
|
||||
@target_bgm_vol_level = -1
|
||||
@bgm_fadein_speed = 0
|
||||
@bgm_fadein_timer = 0
|
||||
@map_bgm = nil
|
||||
@message_text = nil
|
||||
@message_face = nil
|
||||
|
|
@ -111,4 +117,20 @@ class Game_Temp
|
|||
@footstep_sfx = nil
|
||||
@filmsprite = nil
|
||||
end
|
||||
|
||||
def bgm_fadein(game_system)
|
||||
if @target_bgm_vol_level > 0
|
||||
@bgm_fadein_timer += 1
|
||||
if @bgm_fadein_timer > 14
|
||||
@bgm_fadein_timer = 0
|
||||
game_system.playing_bgm.volume += @bgm_fadein_speed
|
||||
if game_system.playing_bgm.volume >= @target_bgm_vol_level
|
||||
game_system.playing_bgm.volume = @target_bgm_vol_level
|
||||
@target_bgm_vol_level = -1
|
||||
@bgm_fadein_speed = 1
|
||||
end
|
||||
game_system.bgm_play(game_system.playing_bgm)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ class Scene_Map
|
|||
end
|
||||
# Loop
|
||||
loop do
|
||||
$game_temp.bgm_fadein($game_system)
|
||||
# Update map, interpreter, and player order
|
||||
# (this update order is important for when conditions are fulfilled
|
||||
# to run any event, and the player isn't provided the opportunity to
|
||||
|
|
|
|||
|
|
@ -117,6 +117,11 @@ module Script
|
|||
$game_map.display_x = x
|
||||
$game_map.display_y = y
|
||||
end
|
||||
|
||||
def self.fadein_bgm(target, speed)
|
||||
$game_temp.target_bgm_vol_level = target
|
||||
$game_temp.bgm_fadein_speed = speed
|
||||
end
|
||||
end
|
||||
|
||||
def has_lightbulb?
|
||||
|
|
|
|||
Loading…
Reference in a new issue