I have been devising a custom title screen by skipping the built-in method and using the initial loaded map. However, the custom title screen code itself is not what I need help with. Instead, I am in need of a brainstorming session to come up with a way to 'schedule' or 'tie' events and/or code to certain time frames of the title screen BGM. In effect, I want the initial title screen animation to survive switching focus away from the game window as well as semi-accurately tying animation to music.
For an example, if the player clicked away from the game window for two seconds, and then clicked back, the initial title screen animation would 'snap' to where it should be at that point in the song. After the initial scroll-up animation is complete and the BGM settles into the loop, I do not need any further scheduling.
To (hopefully) better illustrate what I am after, I have created a quick graphic :
Now, I already have a script that returns the current time value of the BGM and BGS (which I have included in the post). What I really need are some ideas on how to implement what I am after. I suppose I might have to generate some kind of 'keyframe' database for a reference point, but ... I would very much enjoy hearing any other ideas!
Audio Position Script -
For an example, if the player clicked away from the game window for two seconds, and then clicked back, the initial title screen animation would 'snap' to where it should be at that point in the song. After the initial scroll-up animation is complete and the BGM settles into the loop, I do not need any further scheduling.
To (hopefully) better illustrate what I am after, I have created a quick graphic :
Audio Position Script -
Code:
#==============================================================================# Audio Position#==============================================================================# Author : OriginalWij# Updated : Exhydra# Version : 1.1#==============================================================================#==============================================================================# To use: # call: (from a Script Event command)# bgm_position - gets playing BGM position in seconds (float) *# bgs_position - gets playing BGS position in seconds (float) *## * = returns 0 if none playing# examples: $game_variables[42] = bgm_position# RPG::BGS.stop if bgs_position > 42#==============================================================================#==============================================================================# What this does: # allows syncing to music by position (accurate to 0.01 seconds)#==============================================================================#==============================================================================# RPG#==============================================================================module RPG #============================================================================ # BGM #============================================================================ class BGM < AudioFile #------------------------------------------------------------------------ # Variables [New] #------------------------------------------------------------------------ @@position = 0 #------------------------------------------------------------------------ # Play [Mod] #------------------------------------------------------------------------ unless method_defined?(:ow_ap_rpg_bgm_play) alias_method(:ow_ap_rpg_bgm_play, :play) end def play(*args, &block) ow_ap_rpg_bgm_play(*args, &block) @@position = @name.empty? ? 0 : Time.now end #------------------------------------------------------------------------ # Stop [Mod] #------------------------------------------------------------------------ unless method_defined?(:ow_ap_rpg_bgm_stop) class << self alias :ow_ap_rpg_bgm_stop :stop end end def self.stop(*args, &block) ow_ap_rpg_bgm_stop(*args, &block) @@position = 0 end #------------------------------------------------------------------------ # Fade [Mod] #------------------------------------------------------------------------ unless method_defined?(:ow_ap_rpg_bgm_fade) class << self alias :ow_ap_rpg_bgm_fade :fade end end def self.fade(*args, &block) ow_ap_rpg_bgm_fade(*args, &block) @@position = 0 end #------------------------------------------------------------------------ # Position [New] #------------------------------------------------------------------------ def position return 0 if @@position == 0 return Time.now - @@position end end #============================================================================ # BGS #============================================================================ class BGS < AudioFile #------------------------------------------------------------------------ # Variables [New] #------------------------------------------------------------------------ @@position = 0 #------------------------------------------------------------------------ # Play [Mod] #------------------------------------------------------------------------ unless method_defined?(:ow_ap_rpg_bgs_play) alias_method(:ow_ap_rpg_bgs_play, :play) end def play(*args, &block) ow_ap_rpg_bgs_play(*args, &block) @@position = @name.empty? ? 0 : Time.now end #------------------------------------------------------------------------ # Stop [Mod] #------------------------------------------------------------------------ unless method_defined?(:ow_ap_rpg_bgs_stop) class << self alias :ow_ap_rpg_bgs_stop :stop end end def self.stop(*args, &block) ow_ap_rpg_bgs_stop(*args, &block) @@position = 0 end #------------------------------------------------------------------------ # Fade [Mod] #------------------------------------------------------------------------ unless method_defined?(:ow_ap_rpg_bgs_fade) class << self alias :ow_ap_rpg_bgs_fade :fade end end def self.fade(*args, &block) ow_ap_rpg_bgs_fade(*args, &block) @@position = 0 end #------------------------------------------------------------------------ # Position [New] #------------------------------------------------------------------------ def position return 0 if @@position == 0 return Time.now - @@position end end end#==============================================================================# Game_Interpreter#==============================================================================class Game_Interpreter #-------------------------------------------------------------------------- # Get BGM Position [New] #-------------------------------------------------------------------------- def bgm_position return RPG::BGM.last.position end #-------------------------------------------------------------------------- # Get BGS Position [New] #-------------------------------------------------------------------------- def bgs_position return RPG::BGS.last.position end end