Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Screen Fadeout

I need to know how you fade out a scene. I want it the same speed as my fadein. My fadein line is:

Code:
Graphics.transition(100)


How do I fadeout at this same graduate line?
 
You already answered your question. :>

Graphics.transition works both ways. It decides how Scene A transitions to Scene B in optional amount of frames.

To REALLY answer your question, however, put that line in both Scene classes that require such transition.

Code:
class Scene_A

  def main
    ...
    Graphics.transition(100)
    loop do
    ...
    end
    Graphics.freeze
    ...
  end
...
end

class Scene_B

  def main
    ...
    Graphics.transition(100)
    loop do
    ...
    end
    Graphics.freeze
    ...
  end
...
end
In above case, Scene A and Scene B both transitions to each other in 100 frames.

Code:
class Scene_A
  ...
  Graphics.transition(1000)
  ...
end
class Scene_B
  ...
  Graphics.transition(2)
  ...
end
However, in this case, when player is in Scene A, the screen transitions to Scene B in only two frames. When player is in Scene B, transition takes 1000 frames to complete.
 
Okay, I'll explain a bit more.

I'm using a splash screen in my game. Screen fades in, then when you click, it fades back to black. Then it automatically fades to scene_title.
 
Okay, here goes.

Code:
#==============================================================================
# ** Scene_RubyLogo
#------------------------------------------------------------------------------
#  This class makes a Ruby splash screen.  
#==============================================================================

class Scene_RubyIntro
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # If battle test
    if $BTEST
      battle_test
      return
    end
    # Load database
    $data_actors        = load_data("Data/Actors.rxdata")
    $data_classes       = load_data("Data/Classes.rxdata")
    $data_skills        = load_data("Data/Skills.rxdata")
    $data_items         = load_data("Data/Items.rxdata")
    $data_weapons       = load_data("Data/Weapons.rxdata")
    $data_armors        = load_data("Data/Armors.rxdata")
    $data_enemies       = load_data("Data/Enemies.rxdata")
    $data_troops        = load_data("Data/Troops.rxdata")
    $data_states        = load_data("Data/States.rxdata")
    $data_animations    = load_data("Data/Animations.rxdata")
    $data_tilesets      = load_data("Data/Tilesets.rxdata")
    $data_common_events = load_data("Data/CommonEvents.rxdata")
    $data_system        = load_data("Data/System.rxdata")
    # Make system object
    $game_system = Game_System.new
    # Make title graphic
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.picture("Ruby Logo")
    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end
    # Play title BGM
    $game_system.bgm_play($data_system.title_bgm)
    # Stop playing ME and BGS
    Audio.me_stop
    Audio.bgs_stop
    # Execute transition
    Graphics.transition(100)
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of command window
    # Dispose of title graphic
    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update command window
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Branch by command window cursor position
      Graphics.transition(100)
      $scene = Scene_Title.new
    end
    if Input.trigger?(Input::B)
      # Branch by command window cursor position
      Graphics.transition(100)
      $scene = Scene_Title.new
    end
  end
  def battle_test
    # Load database (for battle test)
    $data_actors        = load_data("Data/BT_Actors.rxdata")
    $data_classes       = load_data("Data/BT_Classes.rxdata")
    $data_skills        = load_data("Data/BT_Skills.rxdata")
    $data_items         = load_data("Data/BT_Items.rxdata")
    $data_weapons       = load_data("Data/BT_Weapons.rxdata")
    $data_armors        = load_data("Data/BT_Armors.rxdata")
    $data_enemies       = load_data("Data/BT_Enemies.rxdata")
    $data_troops        = load_data("Data/BT_Troops.rxdata")
    $data_states        = load_data("Data/BT_States.rxdata")
    $data_animations    = load_data("Data/BT_Animations.rxdata")
    $data_tilesets      = load_data("Data/BT_Tilesets.rxdata")
    $data_common_events = load_data("Data/BT_CommonEvents.rxdata")
    $data_system        = load_data("Data/BT_System.rxdata")
    # Reset frame count for measuring play time
    Graphics.frame_count = 0
    # Make each game object
    $game_temp          = Game_Temp.new
    $game_system        = Game_System.new
    $game_switches      = Game_Switches.new
    $game_variables     = Game_Variables.new
    $game_self_switches = Game_SelfSwitches.new
    $game_screen        = Game_Screen.new
    $game_actors        = Game_Actors.new
    $game_party         = Game_Party.new
    $game_troop         = Game_Troop.new
    $game_map           = Game_Map.new
    $game_player        = Game_Player.new
    # Set up party for battle test
    $game_party.setup_battle_test_members
    # Set troop ID, can escape flag, and battleback
    $game_temp.battle_troop_id = $data_system.test_troop_id
    $game_temp.battle_can_escape = true
    $game_map.battleback_name = $data_system.battleback_name
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Switch to battle screen
    $scene = Scene_Battle.new
  end
end

The input trigger lines are where it should turn back to black. The only other way I can think of doing it is unprofessionally with another completely blank scene.
 
EDIT: I misunderstood your post. Looking into it right now, but shouldn't take long...

However:
Code:
    @sprite = Sprite.new
    @sprite.bitmap = RPG::Cache.picture("Ruby Logo")
[highlight]    # If enabled, make @continue_enabled true; if disabled, make it false
    @continue_enabled = false
    for i in 0..3
      if FileTest.exist?("Save#{i+1}.rxdata")
        @continue_enabled = true
      end
    end[/highlight]
    # Play title BGM
    $game_system.bgm_play($data_system.title_bgm)

Delete the highlighted lines because you're not using @continue_enabled variable anyway.
 
And my browser logged me out right after I clicked Submit Reply, thus destroying my to-be post. -_-

Anyway, this is something I don't like and recommend, but you can modify Main to transition between the two scenes.

Code:
begin
  Graphics.freeze
[highlight]  $scene = Scene_RubyIntro.new
  while $scene != nil
    $scene.main
  end
  Graphics.transition(100)
  Graphics.freeze[/highlight]
  $scene = Scene_Title.new
  while $scene != nil
    $scene.main
  end
  Graphics.transition(20)
rescue Errno::ENOENT
  filename = $!.message.sub("No such file or directory - ", "")
  print("File #{filename} was not found.")
end

Make sure Scene_Title has the Graphics.transition(100) in its main method.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top