Ahoy folks,
I did a custom window based on some tutorial and now I'm trying to improve.
The event that calls the window says:
And the result is:
How can I expand the content height of this window? Or make it fits the text size, like the width already does.
I did a custom window based on some tutorial and now I'm trying to improve.
Code:
function Window_Hint() {
this.initialize.apply(this, arguments);
}
Window_Hint.prototype = Object.create(Window_Base.prototype);
Window_Hint.prototype.constructor = Window_Hint;
Window_Hint.prototype.initialize = function(time) {
var width = this.windowWidth();
var height = this.windowHeight();
var x = Graphics.boxWidth - width;
var y = 0;
var timer = time;
Window_Base.prototype.initialize.call(this, x, y, width, height);
var that = this;
setTimeout(function () { that.close(); that.parent.removeChild(that);}, 4000);
this.refresh();
};
Window_Hint.prototype.windowWidth = function() {
return 240;
};
Window_Hint.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
Window_Hint.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
//This doesn't work :(
var height = this.contents.height - this.textPadding() * 2;
this.contents.clear();
};
Window_Hint.prototype.close = function() {
this.contents.clear();
Window_Base.prototype.close.call(this);
};
Window_Hint.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};
The event that calls the window says:
Code:
var hint = new Window_Hint();
hint.height = 120; //This works for the window, but the text doens't fit in the new height.
hint.drawText("text line 1", 0, 0, 200, 'left');
hint.drawText("text in line 2", 0, 25, 200, 'left');
SceneManager._scene.addChild(hint)
And the result is:
How can I expand the content height of this window? Or make it fits the text size, like the width already does.