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.

How to add icons in a menu

erlyn

Member

I would like to know how to simply add icons to the existing menu (next to the item, equipment and so on). I have been looking for hours already on what changes I need to do or add in the script so any help will be appreciated!
 
Here ya go...

Code:
#==============================================================================

# ** Window_Command - Brew

#------------------------------------------------------------------------------

#  This window deals with general command choices.

#  Display an icon if the name matches the menu option

#  Put a matching icon the Graphics\Icons folder. (i.e. Item.png)

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

 

class Window_Command

  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))

    if File.exist?("Graphics\\Icons\\#{@commands[index]}.png")

      bitmap = RPG::Cache.icon(@commands[index])

      opacity = color == disabled_color ? 127 : 255

      rect = bitmap.rect

      self.contents.blt(4, 32 * index, bitmap, rect, opacity) 

      rect = Rect.new(32, 32 * index, self.contents.width - 32, 32)

      self.contents.draw_text(rect, @commands[index])

    else

      self.contents.draw_text(rect, @commands[index])

    end

  end

end

 

Put your icons in the Graphics\Icons folder. Name them the exact same name as the menu option. (Item.png, Skill.png,...)
This will also work in the battle, actor selection window, so you may want to also create an Attack.png & Defend.png
By virtue of coincidence, it will also work in the Title menu, so if you create New Game.png, Continue.png & Shutdown.png, you'll get them there too.

Be Well
 

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