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.

scrolling credit script help

Hi

I've got the scrolling credits script.

The only problem I have with it is It doesn't go back to title screen after the text has finished scrolling. Any Ideas?

Code:
CREDITS_FONT = "Times New Roman"
CREDITS_SIZE = 24
CREDITS_OUTLINE = Color.new(0,0,127, 255)
CREDITS_SHADOW = Color.new(0,0,0, 100)
CREDITS_FILL = Color.new(255,255,255, 255)

#==============================================================================
# ? Scene_Credits
#------------------------------------------------------------------------------
#  Scrolls the credits you make below. Original Author unknown. Edited by
#  MiDas Mike so it doesn't play over the Title, but runs by calling the following:
#  $scene = Scene_Credits.new
#==============================================================================

class Scene_Credits

  # This next piece of code is the credits.
  
    CREDIT=<<_END_

    
Eternity's End
Version 1.0.0

Notes
---------------
All music encoded with the GNU opensource
LAME Mp3 Encoder, full info at below website:
www.mp3dev.org

Thank you for playing this game. We hope you enjoyed it. Watch for
other titles by Adsoft Productions in the future..

_END_
  def main
    
    #-------------------------------
    # Animated Background Setup
    #-------------------------------
    @sprite = Sprite.new
    Audio.bgm_play ("AUDIO/BGM/Credits", 90, 100)
    #@sprite.bitmap = RPG::Cache.title($data_system.title_name)
    @backgroundList = ["CreditsTitle"] #Edit this to the title screen(s) you wish to show in the background. They do repeat.
    @backgroundGameFrameCount = 0
    # Number of game frames per background frame.
    @backgroundG_BFrameCount = 3.4
    @sprite.bitmap = RPG::Cache.title(@backgroundList[0])
    
    #------------------
    # Credits Setup
    #------------------
    
    credit_lines = CREDIT.split(/\n/)
    credit_bitmap = Bitmap.new(640,32 * credit_lines.size)
    credit_lines.each_index do |i|
      line = credit_lines[i]
      credit_bitmap.font.name = CREDITS_FONT
      credit_bitmap.font.size = CREDITS_SIZE
      x = 0
       credit_bitmap.font.color = CREDITS_OUTLINE
       credit_bitmap.draw_text(0 + 1,i * 32 + 1,640,32,line,1)
       credit_bitmap.draw_text(0 - 1,i * 32 + 1,640,32,line,1)
       credit_bitmap.draw_text(0 + 1,i * 32 - 1,640,32,line,1)
       credit_bitmap.draw_text(0 - 1,i * 32 - 1,640,32,line,1)
       credit_bitmap.font.color = CREDITS_SHADOW
       credit_bitmap.draw_text(0,i * 32 + 8,640,32,line,1)
       credit_bitmap.font.color = CREDITS_FILL
      credit_bitmap.draw_text(0,i * 32,640,32,line,1)
    end
    @credit_sprite = Sprite.new(Viewport.new(0,50,640,380))
    @credit_sprite.bitmap = credit_bitmap
    @credit_sprite.z = 9998
    @credit_sprite.oy = -430
    @frame_index = 0
    @last_flag = false
    
    #--------
    # Setup
    #--------
    
    # ME?BGS ??????
    Audio.me_stop
    Audio.bgs_stop
    Audio.se_stop
    # ?????????
    Graphics.transition
    # ??????
    loop do
      # ????????
      Graphics.update
      # ???????
      Input.update
      # ??????
      update
      # ????????????????
      if $scene != self
        break
      end
    end
    # ?????????
    Graphics.freeze
    @sprite.dispose
    @credit_sprite.dispose
  end
  
  #Checks if credits bitmap has reached it's ending point
  def last?
    return (@frame_index >= @credit_sprite.bitmap.height + 480)
  end
  def last
    if not @last_flag
      @last_flag = true
      @last_count = 0
    else
      @last_count += 1
    end
    if @last_count >= 300
      $scene = Scene_Title.new
    end
  end
  
  #Check if the credits should be cancelled
    def cancel?
    if Input.trigger?(Input::C)
      $scene = Scene_Title.new
      return true
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def update
    @backgroundGameFrameCount = @backgroundGameFrameCount + 1
    if @backgroundGameFrameCount >= @backgroundG_BFrameCount
     @backgroundGameFrameCount = 0
     # Add current background frame to the end
     @backgroundList = @backgroundList << @backgroundList[0]
     # and drop it from the first position
     @backgroundList.delete_at(0)
     @sprite.bitmap = RPG::Cache.title(@backgroundList[0])
   end
    return if cancel?
    last if last?
    @credit_sprite.oy += 1
  end
end

any help would be greatly appreciated.
 
Hmm, looks like your missing something. I'm not familiar with the script, but I think the way it works is it increases a variable called @frame_index, and when this number reaches a certain point, it exits the credits. However, in the code, this variable isn't updated, so it can never reach that "point"...lemme see if I can figure out where to put this.

[EDIT]
Woops, never mind my rambling...you need to press a key to quit. I'll code an option for it to automatically exit in a bit.
 
Ok, add this bit of code immediately after @credit_sprite.oy += 1, between lines 146 and 147.

Code:
     #Check if the bitmap scrolled all the way up
     if @credit_sprite.oy > @credit_sprite.bitmap.height + 25
       $scene = Scene_Title.new
     end

This will return to the title screen after it has finished scrolling automatically.
 

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