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.

Assign element Icons?

Well, I've seen in several scripts (Like Dargor Bestiary or DVV Skill/Item description), That is possible to assign Icons to the Elements, I refer to Fire, Water...etc.

The problem is that the Class Element belongs to RPG::System, and I don't know how to assign or add atrributes to the Element Subscript.

Or something like:

module RPG::Element

Element Icons = {Fire => '001-Icon01',......}
Element_Icons.default = Iconx

Because there are no a Element class.
 
Just put your constant in RPG::System or something. You don't have to really put attributes into a specific class.

Code:
class RPG::System

  Element_Icons = [nil, 'Filename', 'Filename', ...]

end

The method above just uses an array. If you want to get the icon, you just have to use something like:
Code:
icon = RPG::Icon(Element_Icons[element_id])

You could also use a hash, with element name as key and icon as value (letting you put defaults if you want).
 

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