[RMVX ACE] SUPER SIMPLE ANIMATED TITLE SCREEN: SMOOTHER TRANSITION?

Posts

Pages: 1
I'm using this script made by TheoAllen for RM Vx Ace to display more than one title screen. I just wanted to ask if someone could help me making the transition between the BGs more "smooth". My title pictures represent the transition from day to night, so it would be nice if they wouldn't change so abrupt. For example, it would be great if one BG fades out while the next BG fades in. Is this possible?

Thanks in advance. :)

#===============================================================================

# Super Simple Animated Title Screen
# By: TheoAllen
# EDIT: Tw0Face
#-------------------------------------------------------------------------------
# Getting tired of animated title screen that offers you a lot of things you
# don't even need? And why not just use traditional frame per frame animation
# background?
#
# This script is an answer for you
#
# Terms of Use
# Free for commercial and non-commercial
#===============================================================================
module SSAnimTitle

# Set the frame here. Note that it will ONLY change the title1. And will not
# animate the border part (title2)
BackGround = [
"Traventor_Title1",
"Traventor_Title2",
"Traventor_Title3",
"Traventor_Title4",
"Traventor_Title5",
]

# Frame rate. Higher = slower
Rate = 180
end
#===============================================================================
# End of config
#===============================================================================
module Cache
def self.dispose(path)
@cache[path].dispose if @cache[path] && !@cache[path].disposed?
end
end

class Scene_Title

alias ss_anim_title_start start
def start
ss_anim_title_start
precache_animation
@count = 0
#@bg_index = 0
if @bg_index != nil then
@bg_index -= 1
refresh_bg
else
@bg_index = 0
end
end

def precache_animation
SSAnimTitle::BackGround.each do |name|
Cache.title1(name)
end
end

alias ss_anim_title_update update
def update
ss_anim_title_update
@count += 1
refresh_bg if @count % SSAnimTitle::Rate == 0
end

def refresh_bg
@bg_index += 1
@bg_index %= SSAnimTitle::BackGround.size
@sprite1.bitmap = Cache.title1(SSAnimTitle::BackGround[@bg_index])
center_sprite(@sprite1)
end

alias ss_anim_title_terminate terminate
def terminate
ss_anim_title_terminate
SSAnimTitle::BackGround.each do |name|
Cache.dispose("Graphics/Titles1/" + name)
end
end
end
Marrend
Guardian of the Description Thread
21781
Hack methods are hack.

#===============================================================================
# Super Simple Animated Title Screen
# By: TheoAllen
# EDIT: Tw0Face
# Further editing by Marrend
#-------------------------------------------------------------------------------
# Getting tired of animated title screen that offers you a lot of things you
# don't even need? And why not just use traditional frame per frame animation
# background?
#
# This script is an answer for you
#
# Terms of Use
# Free for commercial and non-commercial
#===============================================================================
module SSAnimTitle
 
  # Set the frame here. Note that it will ONLY change the title1. And will not
  # animate the border part (title2)
  BackGround = [
  #"Traventor_Title1",
  #"Traventor_Title2",
  #"Traventor_Title3",
  #"Traventor_Title4",
  #"Traventor_Title5",
  "Plain",
  "Night",
  "Island",
  "Gates",
  "Crystal"
  ]
  
  BGM = [
  "Theme1",
  "Theme2",
  "Theme3",
  "Theme4",
  "Theme5"
  ]
 
  # Frame rate. Higher = slower
  Rate = 180
end

#===============================================================================
# End of config
#===============================================================================

module Cache
  def self.dispose(path)
    @cache[path].dispose if @cache[path] && !@cache[path].disposed?
  end
end

class Scene_Title 
  alias ss_anim_title_start start
  def start
    ss_anim_title_start
    precache_animation
    @count = 0
    #@bg_index = 0
    if @bg_index != nil then
      @bg_index -= 1
    else
      @bg_index = 0
    end
    refresh_bg
    set_bgm
  end
 
  def precache_animation
    SSAnimTitle::BackGround.each do |name|
      Cache.title1(name)
    end
  end
 
  alias ss_anim_title_update update
  def update
    ss_anim_title_update
    @count += 1
    if @count % SSAnimTitle::Rate == 0
      refresh_bg
      set_bgm
    end
  end
  
  def set_bgm
    @bgm = RPG::BGM.new
    @bgm.name = SSAnimTitle::BGM[@bg_index]
    @bgm.play
    RPG::BGM.fade(SSAnimTitle::Rate * 30) #Graphics.frame_rate)
  end
  
  def refresh_bg
    @bg_index += 1
    @bg_index %= SSAnimTitle::BackGround.size
    @sprite1.bitmap = Cache.title1(SSAnimTitle::BackGround[@bg_index])
    center_sprite(@sprite1)
  end
 
  alias ss_anim_title_terminate terminate
  def terminate
    ss_anim_title_terminate
    SSAnimTitle::BackGround.each do |name|
      Cache.dispose("Graphics/Titles1/" + name)
    end
  end
end

For full disclosure, I was using RTP resources with this attempt. Replace/uncomment file names as appropriate. The main issue seems to be that the "fade" function is passed a value for a fade-time in milliseconds. Most other functions use frames to track time passed.

I figured the BGM fading should align with how often the backgrounds change, hence the use of SSAnimTitle::Rate. Leaving the value as-is is no good. The music lasts for maybe 1 second before it's faded out completely, and basically sounds cut off. As you can see, I initially multiplied the rate by Graphics.frame_rate. However, multiplying it by 30 sounded/felt a little better to me. You're welcome to fudge the numbers.
Hi, Marrend. Sorry, that's not what I was looking for. I was looking for a transition for the Title1 BGs (background images), not BGM (background music).
Marrend
Guardian of the Description Thread
21781
Welp. My mistake. Re-try.

#===============================================================================
# Super Simple Animated Title Screen
# By: TheoAllen
# EDIT: Tw0Face
#-------------------------------------------------------------------------------
# Getting tired of animated title screen that offers you a lot of things you
# don't even need? And why not just use traditional frame per frame animation
# background?
#
# This script is an answer for you
#
# Terms of Use
# Free for commercial and non-commercial
#===============================================================================
module SSAnimTitle
 
  # Set the frame here. Note that it will ONLY change the title1. And will not
  # animate the border part (title2)
  BackGround = [
  #"Traventor_Title1",
  #"Traventor_Title2",
  #"Traventor_Title3",
  #"Traventor_Title4",
  #"Traventor_Title5",
  "Plain",
  "Night",
  "Island",
  "Gates",
  "Crystal"
  ]
  # Frame rate. Higher = slower
  Rate = 180
end

#===============================================================================
# End of config
#===============================================================================

module Cache
  def self.dispose(path)
    @cache[path].dispose if @cache[path] && !@cache[path].disposed?
  end
end

class Scene_Title < Scene_Base
 alias ss_anim_title_start start
  def start
    ss_anim_title_start
    precache_animation
    @count = 0
    @bg_index = 0
    @temp_bg = Sprite.new
    set_bg
  end

  def fade_rate
    255 * @count / SSAnimTitle::Rate
  end
 
  def precache_animation
    SSAnimTitle::BackGround.each do |name|
      Cache.title1(name)
    end
  end
 
  alias ss_anim_title_update update
  def update
    ss_anim_title_update
    @count += 1
    refresh_bg
    if @count % SSAnimTitle::Rate == 0
      set_bg
      @count = 0
    end
  end
  
  def set_bg
    #@bg_index += 1
    @bg_index %= SSAnimTitle::BackGround.size
    @sprite1.bitmap = Cache.title1(SSAnimTitle::BackGround[@bg_index])
    @temp_bg.opacity = 0
    @temp_bg.bitmap = Cache.title1(next_bg)
    center_sprite(@sprite1)
    center_sprite(@temp_bg)
    @bg_index += 1
  end
  
  def next_bg
    index = (@bg_index + 1) % SSAnimTitle::BackGround.size
    return SSAnimTitle::BackGround[index]
  end
    
  def refresh_bg
    @temp_bg.opacity = fade_rate
  end
 
  alias ss_anim_title_terminate terminate
  def terminate
    ss_anim_title_terminate
    SSAnimTitle::BackGround.each do |name|
      Cache.dispose("Graphics/Titles1/" + name)
    end
  end
end

These transitions seem pretty smooth to me. It was the extra...

@temp_bitmap.opacity = 0

...in the "set_bg" function that seemed to do it. Otherwise, there was obvious flickering.
That's exactly what I was looking for! Thanks a lot, Marrend. I'm very grateful. Only problem is, when I hit "Continue" and leave it with ESC, the background immediately jumps back to the very first one. Is there a way to prevent the script from doing this?
Marrend
Guardian of the Description Thread
21781
It seems...

alias ss_anim_title_start start
def start
  ss_anim_title_start
  precache_animation
  @count = 0
  if @bg_index == nil; @bg_index = 0; end;
  @temp_bg = Sprite.new
  set_bg
end

#etc

...this works. From what I'm observing on my end, this works because "Continue" calls Scene_Load, and the "return_scene" function there refers back to Scene_Title. If Scene_Title is called from Scene_End, the "return_scene" function in Scene_End would refer to Scene_Menu instead. Scene_Title has lost relevancy/context/focus/whatever, making "@bg_index" return to a "nil" state.
This works like a charm. I'm overwhelmed! Thank you so much for your help, Marrend.
Marrend
Guardian of the Description Thread
21781
Happy to be of service!
@Marrend: Hm, I did a bit of testing and I figured out that when you leave the loading screen with ESC, the BG doesn't jump to the first one anymore, but skips over to the next one in line. So it kinda skips the transition. No idea if this is possible, but maybe there's a way to freeze the fading while in the loading screen and start fading again from that point after leaving with ESC?
Marrend
Guardian of the Description Thread
21781
#===============================================================================
# Super Simple Animated Title Screen
# By: TheoAllen
# EDIT: Tw0Face
#-------------------------------------------------------------------------------
# Getting tired of animated title screen that offers you a lot of things you
# don't even need? And why not just use traditional frame per frame animation
# background?
#
# This script is an answer for you
#
# Terms of Use
# Free for commercial and non-commercial
#===============================================================================
module SSAnimTitle
 
  # Set the frame here. Note that it will ONLY change the title1. And will not
  # animate the border part (title2)
  BackGround = [
  #"Traventor_Title1",
  #"Traventor_Title2",
  #"Traventor_Title3",
  #"Traventor_Title4",
  #"Traventor_Title5",
  "Plain",
  "Night",
  "Island",
  "Gates",
  "Crystal"
  ]
  # Frame rate. Higher = slower
  Rate = 180
end

#===============================================================================
# End of config
#===============================================================================

module Cache
  def self.dispose(path)
    @cache[path].dispose if @cache[path] && !@cache[path].disposed?
  end
end

class Scene_Title < Scene_Base
  alias ss_anim_title_start start
  def start
    ss_anim_title_start
    precache_animation
    if @count == nil; @count = 0; end;
    if @bg_index == nil; @bg_index = 0; end;
    @temp_bg = Sprite.new
    set_bg
  end

  def fade_rate
    255 * @count / SSAnimTitle::Rate
  end
 
  def precache_animation
    SSAnimTitle::BackGround.each do |name|
      Cache.title1(name)
    end
  end
 
  alias ss_anim_title_update update
  def update
    ss_anim_title_update
    @count += 1
    refresh_bg
    if @count % SSAnimTitle::Rate == 0
      @count = 0
      @bg_index += 1
      set_bg
    end
  end
  
  def set_bg
    @bg_index %= SSAnimTitle::BackGround.size
    @sprite1.bitmap = Cache.title1(SSAnimTitle::BackGround[@bg_index])
    refresh_bg
    @temp_bg.bitmap = Cache.title1(next_bg)
    center_sprite(@sprite1)
    center_sprite(@temp_bg)
  end
  
  def next_bg
    index = (@bg_index + 1) % SSAnimTitle::BackGround.size
    return SSAnimTitle::BackGround[index]
  end
    
  def refresh_bg
    @temp_bg.opacity = fade_rate
  end
 
  alias ss_anim_title_terminate terminate
  def terminate
    ss_anim_title_terminate
    SSAnimTitle::BackGround.each do |name|
      Cache.dispose("Graphics/Titles1/" + name)
    end
  end
end

*Edit: So, we apply the same logic/code to "@count" as we did "@bg_index". The "update" method has been altered to increment "@bg_index", and reset "@count" when "@count" reaches "SSAnimTitle::Rate". The "set_bg" function calls the "refresh_bg" function to apply the opacity of "@temp_bg" via "@count", rather than set it to 0. The end result has at least the appearance that the image and current fade are retained. I'm not 100% sure if we need to use the modulus operator for the comparison of "@count" versus "SSAnimTitle::Rate", but, as it is sometimes said, if it ain't broke, don't fix it!
Now it's perfect! Thanks again. :)
Pages: 1