Recently, I wanted to create a script.
How does it work?
@window = Window_textbox.new
@window.event_text("event!")
If you enter the script as above, you wanted to set the length of the sentence in parentheses in @window.event_text to the width of the text box.
However, when I created and ran the script, there was an error called disposed window.
The script is as follows.
class Window_textbox < Window_Base
def initialize(x = 256,y = 192,width = cal_width(), height = 50)
super(x,y,width,height)
end
def event_text(text)
return unless text.is_a?(String)
draw_text(text, 0, 0, 128, 25)
end
def draw_text(text, x, y, text_width, text_height, aligment = 0)
contents.draw_text(x, y, text_width, text_height, text, aligment)
end
end
def cal_width()
bt = Bitmap.new(1, 1)
rect= bt.text_size(contents.draw_text)
bt.dispose
return rect.width
end
I don't know how to fix it. Please help me.
How does it work?
@window = Window_textbox.new
@window.event_text("event!")
If you enter the script as above, you wanted to set the length of the sentence in parentheses in @window.event_text to the width of the text box.
However, when I created and ran the script, there was an error called disposed window.
The script is as follows.
class Window_textbox < Window_Base
def initialize(x = 256,y = 192,width = cal_width(), height = 50)
super(x,y,width,height)
end
def event_text(text)
return unless text.is_a?(String)
draw_text(text, 0, 0, 128, 25)
end
def draw_text(text, x, y, text_width, text_height, aligment = 0)
contents.draw_text(x, y, text_width, text_height, text, aligment)
end
end
def cal_width()
bt = Bitmap.new(1, 1)
rect= bt.text_size(contents.draw_text)
bt.dispose
return rect.width
end
I don't know how to fix it. Please help me.