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.

Change font color in title screen

Status
Not open for further replies.
I know the following code can be placed in a script to change text color.
self.contents.font.color = Color.new(-255,-255,-255,-255)
I want to change the font color only in the title screen but not in any of the other command windows. Does anyone know where I can place this code? Or do I need to do something else? Btw, all -255 equals black, right?
 

Mac

Member

What you need to do is:- Create a new script below Window_Command and call this Window_Command2.

The paste this code into it:-

Code:
#==============================================================================
# ** Window_Command2
#------------------------------------------------------------------------------
#  This window deals with general command choices.
#==============================================================================

class Window_Command2 < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width    : window width
  #     commands2 : command text string array
  #--------------------------------------------------------------------------
  def initialize(width, commands2)
    # Compute window height from command quantity
    super(0, 0, width, commands.size * 32 + 32)
    @item_max = commands2.size
    @commands2 = commands2
    # This is the part where you can change the colours.
    self.contents.font.color = Color.new(-255,-255,-255,-255)
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #     color : text color
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands2[index])
  end
  #--------------------------------------------------------------------------
  # * Disable Item
  #     index : item number
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end

Then go to Scene_Title and go to line 43:-

Code:
    @command_window = Window_Command.new(192, [s1, s2, s3])

And change this too.

Code:
    @command_window = Window_Command2.new(192, [s1, s2, s3])
 
I tried it but received an error. It said that a name error ocurred at line 15 of windowcommand2 and that there was an undefined local variable or method. Do you think it's because there's a number in the new window name?

**EDIT**
I figured out that line 15 needed a 2 by window. But I'm still getting a no method error at line 19 which is the font color line. Ironically, this is the same error that I had originally received before adding your script.
 
Thank you, that worked. The only thing is I had to change the color on the line under draw item because that line overrode the first one. But it finally works! Thanks to everyone who helped me out.
 

Anonymous

Guest

This topic has been resolved. If alexia or any other users have any questions or further problems regarding this topic, please create a new thread about them.

Thank you!
 
Status
Not open for further replies.

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