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.

Odd window initialization problem

Status
Not open for further replies.

khmp

Sponsor

I have an odd problem with an initialize method of custom window I'm making. The window derives from Window_Selectable.
Code:
class Window_Inventory < Window_Selectable
  attr_accessor :n_tier # the type of inventory you are looking at.
  
  # Constants for use in altering the n_tier variable
  ITEMS = 0 
  EQUIP = 1
  K_ITEMS = 2
  
  # Do we want annoying message boxes that help?
  DEBUG_OUT = true

#--------------------------------------------------------------------------
# * Initialize - Start the window inventory.
#--------------------------------------------------------------------------
  def intialize(x, y, width, height)
    if DEBUG_OUT
      print("Window_Inventory initialize begin")
    end
    super(x, y, width, height)
    
    @n_tier = ITEMS
    @data = []
    
    #dummy test
    @data.push("1 apple")
    @data.push("2 bats")
    @data.push("3 sheepies")
    
    self.contents.font.name = $window_font
    self.contents.font.size = $window_font_size
    self.index = 0
    self.contents = Bitmap.new(width - 32, height - 32)
    
    if DEBUG_OUT
      print(@data[0] + ' ' + @data[1] + ' ' + @data[2])
    end
    
    if DEBUG_OUT
      print("Window_Inventory initialize end")
    end
  end
  ...
end

None of the code seems to be executed within initialize. This is one odd bug. The window gets created with the correct dimensions. But I have no idea how! Now just in case you are thinking that the message boxes aren't being displayed because of how they are laid out. Outside the if statement they are just as useless. Also the class scope variable @data which should contain three strings contains nil when accessed from any other method in the class. So I have a few questions about this.

1.) Does initialize act as a constructor like in C code? So when 'new' is called for an object this method is automatically called?
2.) How is it possible that the window is created while skipping that code?:'(
3.) Am I overlooking something obvious?

Thanks for taking the time to read this.:thumb:

- Sincerely khmp
 

khmp

Sponsor

You sir are a genius problem solved! I spelled it correctly every where else but where it mattered :( Honestly how hard did you laugh when you found that?:D Thanks again Trickster.
 
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