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.

credits

I've been having a problem with Credits Menu
it doesn't scroll so i can't see everything i got 38 lines

Code:
#===============================================================================
# * Credits Menu
#-------------------------------------------------------------------------------
# A credits menu that scrolls up the Title Screen. Useful for a professional
# looking game.
#===============================================================================
class Window_Scroll < Window_Base
  attr_accessor :credits
  def initialize
    super(0,1,640,480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.back_opacity = 0
    initcredit
    refresh
  end
  def initcredit
    #PUT Credits HERE
    @credits = Hash.new("")
    @credits[0] = "La Salle"
    @credits[1] = " "
    @credits[2] = "Created"
    @credits[3] = "by"
  end
  def refresh
    self.contents.clear
    self.contents.font.color = Color.new(73,73,80)
    self.contents.font.size = 12
    self.contents.font.name = 'Tahoma'
    for i in 0...@credits.size
      self.contents.draw_text(0, 1, 480, (i * 38) + 38, @credits[i].to_s)
    end
  end
end
class Scene_Title
  alias mains89 main
  alias updates89 update
  def main
    mains89
    @scroll_window.dispose
  end
  def update
    @scroll_window.update
    updates89
  end
end
 

khmp

Sponsor

Wow... uh please, please from now on. Don't center everything. Especially code you want help on. If the fix were easy to see it no longer will be if it looks like that.

Is this something you've made? You should really use constants to dictate some of the more important properties of the window. Text size, font, color, alignment perhaps even place the Credits hash in the constants. The problem though was with how you were creating the window. If you create a window before $game_system is initialized you will run into a problem because the windowskin has yet to be named. The windowskin is set inside Window_Base's initialize. $game_system is initialized within the Scene_Title.main code that is aliased. Ok the name Window_Scroll is kind of misleading in this case. Is the text supposed to scroll? Or does the window move?

Example:
Code:
#==============================================================================
# * Credits Menu
#------------------------------------------------------------------------------
# A credits menu that scrolls up the Title Screen. Useful for a professional
# looking game.
#==============================================================================

class Window_Scroll < Window_Base
  #--------------------------------------------------------------------------
  # * Constant Variables
  #--------------------------------------------------------------------------
  Text_Size   = 24                    # The size of the font to use
  Text_Font   = 'Tahoma'              # The font face to use.
  Text_Color  = Color.new(255, 255, 255) # The color used when drawing text.
  Text_Align  = 1                     # 0 - Left, 1 - Center, 2 - Right
  Credits     = [
    'La Salle',
    '',
    'Created',
    'by',
  ]
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :credits
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.back_opacity = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    
    self.contents.font.color = Text_Color
    self.contents.font.size = Text_Size
    self.contents.font.name = Text_Font
    
    for i in 0...Credits.size
      self.contents.draw_text(0, i * Text_Size, 640, Text_Size, 
        Credits[i].to_s, Text_Align)
    end
  end
end

class Scene_Title
  alias mains89 main
  alias updates89 update
  
  def main
    $data_system = load_data("Data/System.rxdata")
    $game_system = Game_System.new
    @scroll_window = Window_Scroll.new
    mains89
    @scroll_window.dispose
  end
  
  def update
    @scroll_window.update
    updates89
  end
end

Good luck with it denzelsoto! :thumb:
 
wow thanks and its not my script
i just found it and i was trying to fix it
hahaha sorry didn't know i centered the code to
i mean the text scrolls
and can it be possible that the text is behind
the new game button the window selectable buttons

[edit]
also when i continued the game its still there
until i fought an enemy

khmp: Please don't double post. Just edit the first one. Thanks.
 

khmp

Sponsor

denzelsoto":1dg7qnvm said:
wow thanks and its not my script
i just found it and i was trying to fix it
hahaha sorry didn't know i centered the code to
i mean the text scrolls
and can it be possible that the text is behind
the new game button the window selectable buttons

Yes in fact it should be. If you are referring to the z value. The z value is what dictates drawing order. Items that are drawn first, meaning they have low z values, are overlapped by items that are drawn later, meaning that they have higher z values. Now objects that aren't assigned a z value default to 0. Neither the command window that displays "New Game", "Continue", "Exit Game" or the window you created are given a specific z value. So both are zero. Which one draws first? The first one created draws first. In this case your custom window will draw first. So technically it already is behind the command window. Unless I'm missing something. If you are referring to position on screen and want it to be drawn behind the same position as the command window than you need to play with this line:
Code:
super(0, 0, 640, 480)
The first two numbers passed into this method are the x and y coordinate of where the window will be, respectively speaking. Open up the script editor go to Scene_Title. Look up "@command_window" and look for how it's x and y are initialized.

Ok with the window sticking around problem. The window isn't being disposed of properly. If your code doesn't reach:
Code:
@scroll_window.dispose
It will hang around until garbage cleanup decides it's time for it to go.

Good luck with it denzelsoto! :thumb:
 

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