Hello,
I have a problem.I created a script that created a new scene which had a window in it. Then i used an event to call the scene by putting a script like this SceneManager.goto(Sample_Scene);
But every time i active the event it shows an error:
TypeError
Cannot read property 'apply' of undefined
This is the script itself:
function Window_Sample() {
this.initialize.apply(this, arguments);
}
Window_Sample.prototype = Object.create(Window_Base.prototype);
Window_Sample.prototype.constructor = Window_Sample;
Window_Sample.prototype.initialize = function(x, y) {
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.refresh();
};
Window_Sample.prototype.windowWidth = function() {
return 240;
};
Window_Sample.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
this.drawIcon(2, 0, 0);
};
Window_Sample.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};
function Sample_Scene() {
this.initialize.apply(this, arguments);
}
Sample_Scene.prototype = Object.create(Sample_MenuBase.prototype);
Sample_Scene.prototype.constructor = Sample_Scene;
Sample_Scene.prototype.initialize = function() {
Sample_MenuBase.prototype.initialize.call(this);
};
Sample_Scene.prototype.create = function() {
Sample_MenuBase.prototype.create.call(this);
this._sampleWindow = new Window_Sample(0,0);
this._sampleWindow.x = Graphics.width / 2 - 100;
this._sampleWindow.y = Graphics.height / 2 - 100;
this.addWindow(this._sampleWindow);
};
Sample_Scene.prototype.start = function() {
Sample_MenuBase.prototype.start.call(this);
};
I have a problem.I created a script that created a new scene which had a window in it. Then i used an event to call the scene by putting a script like this SceneManager.goto(Sample_Scene);
But every time i active the event it shows an error:
TypeError
Cannot read property 'apply' of undefined
This is the script itself:
function Window_Sample() {
this.initialize.apply(this, arguments);
}
Window_Sample.prototype = Object.create(Window_Base.prototype);
Window_Sample.prototype.constructor = Window_Sample;
Window_Sample.prototype.initialize = function(x, y) {
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.refresh();
};
Window_Sample.prototype.windowWidth = function() {
return 240;
};
Window_Sample.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
Window_Sample.prototype.refresh = function() {
var x = this.textPadding();
var width = this.contents.width - this.textPadding() * 2;
this.contents.clear();
this.drawIcon(2, 0, 0);
};
Window_Sample.prototype.open = function() {
this.refresh();
Window_Base.prototype.open.call(this);
};
function Sample_Scene() {
this.initialize.apply(this, arguments);
}
Sample_Scene.prototype = Object.create(Sample_MenuBase.prototype);
Sample_Scene.prototype.constructor = Sample_Scene;
Sample_Scene.prototype.initialize = function() {
Sample_MenuBase.prototype.initialize.call(this);
};
Sample_Scene.prototype.create = function() {
Sample_MenuBase.prototype.create.call(this);
this._sampleWindow = new Window_Sample(0,0);
this._sampleWindow.x = Graphics.width / 2 - 100;
this._sampleWindow.y = Graphics.height / 2 - 100;
this.addWindow(this._sampleWindow);
};
Sample_Scene.prototype.start = function() {
Sample_MenuBase.prototype.start.call(this);
};