I have an odd problem with an initialize method of custom window I'm making. The window derives from Window_Selectable.
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
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