So I'm running into this problem on a plugin I'm trying to put together, and I can't figure out for the life of me why the code seems to be following all the way back to this.drawFace, yet throwing the 'undefined is not a function' error at it.
This is the code in question:
I went ahead and redefined the Window_Base functions (drawActorFace and drawFace) but it didn't do any good. The only other section of the plugin that shows up in the debug error is this:
- and it just flags the 'this._mentorWindow.setActor(mentor);' call line. The whole flow of errors is:
Would love any help. Been banging my head against this for too long!
This is the code in question:
//=============================================================================
// Teamwork_Mentor Window
//=============================================================================
function Window_Teamwork_Mentor() {
this.initialize.apply(this, arguments);
};
Window_Teamwork_Mentor.prototype = Object.create(Window_Base.prototype);
Window_Teamwork_Mentor.prototype.constructor = Window_Teamwork_Mentor;
Window_Teamwork_Mentor.prototype.initialize = function(x, y) {
Window_Base.prototype.initialize.call(this, x, y, 200, 200);
this._actor = null;
};
Window_Teamwork_Mentor.prototype.setActor = function(actor) {
if (this._actor !== actor) {
this._actor = actor;
this.refresh();
}
};
Window_Teamwork_Mentor.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
width = width || Window_Base._faceWidth;
height = height || Window_Base._faceHeight;
var bitmap = ImageManager.loadFace(faceName);
var pw = Window_Base._faceWidth;
var ph = Window_Base._faceHeight;
var sw = Math.min(width, pw);
var sh = Math.min(height, ph);
var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
var sx = faceIndex % 4 * pw + (pw - sw) / 2;
var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2;
this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy);
};
Window_Teamwork_Mentor.prototype.drawActorFace = function(actor, x, y, width, height) {
this.drawFace(actor.faceName(), actor.faceIndex(), x, y, width, height);
};
Window_Teamwork_Mentor.prototype.refresh = function() {
this.contents.clear();
if (this._actor) {
var w = this.width - this.padding * 2;
var h = this.height - this.padding * 2;
var y = h / 2 - this.lineHeight() * 1.5;
var width = w - 162 - this.textPadding();
this.drawActorFace(this._actor, 0, 0, 144, h);
// this.drawActorSimpleStatus(this._actor, 162, y, width);
}
};
// Teamwork_Mentor Window
//=============================================================================
function Window_Teamwork_Mentor() {
this.initialize.apply(this, arguments);
};
Window_Teamwork_Mentor.prototype = Object.create(Window_Base.prototype);
Window_Teamwork_Mentor.prototype.constructor = Window_Teamwork_Mentor;
Window_Teamwork_Mentor.prototype.initialize = function(x, y) {
Window_Base.prototype.initialize.call(this, x, y, 200, 200);
this._actor = null;
};
Window_Teamwork_Mentor.prototype.setActor = function(actor) {
if (this._actor !== actor) {
this._actor = actor;
this.refresh();
}
};
Window_Teamwork_Mentor.prototype.drawFace = function(faceName, faceIndex, x, y, width, height) {
width = width || Window_Base._faceWidth;
height = height || Window_Base._faceHeight;
var bitmap = ImageManager.loadFace(faceName);
var pw = Window_Base._faceWidth;
var ph = Window_Base._faceHeight;
var sw = Math.min(width, pw);
var sh = Math.min(height, ph);
var dx = Math.floor(x + Math.max(width - pw, 0) / 2);
var dy = Math.floor(y + Math.max(height - ph, 0) / 2);
var sx = faceIndex % 4 * pw + (pw - sw) / 2;
var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2;
this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy);
};
Window_Teamwork_Mentor.prototype.drawActorFace = function(actor, x, y, width, height) {
this.drawFace(actor.faceName(), actor.faceIndex(), x, y, width, height);
};
Window_Teamwork_Mentor.prototype.refresh = function() {
this.contents.clear();
if (this._actor) {
var w = this.width - this.padding * 2;
var h = this.height - this.padding * 2;
var y = h / 2 - this.lineHeight() * 1.5;
var width = w - 162 - this.textPadding();
this.drawActorFace(this._actor, 0, 0, 144, h);
// this.drawActorSimpleStatus(this._actor, 162, y, width);
}
};
I went ahead and redefined the Window_Base functions (drawActorFace and drawFace) but it didn't do any good. The only other section of the plugin that shows up in the debug error is this:
Scene_Teamwork.prototype.onActorOk = function() {
// this._actorWindow.processOk();
var mentor = $gameParty.members()[this._actorWindow.index()]._actorId;
this._mentorWindow.setActor(mentor);
this.hideSubWindow(this._actorWindow, this._selectWindow);
};
// this._actorWindow.processOk();
var mentor = $gameParty.members()[this._actorWindow.index()]._actorId;
this._mentorWindow.setActor(mentor);
this.hideSubWindow(this._actorWindow, this._selectWindow);
};
TypeError: undefined is not a function
at Window_Teamwork_Mentor.drawActorFace (ZephAM_TeamworkSys.js:501)
at Window_Teamwork_Mentor.refresh (ZephAM_TeamworkSys.js:511)
at Window_Teamwork_Mentor.setActor (ZephAM_TeamworkSys.js:477)
at Scene_Teamwork.onActorOk (ZephAM_TeamworkSys.js:326)
at Window_Teamwork_Mentor.drawActorFace (ZephAM_TeamworkSys.js:501)
at Window_Teamwork_Mentor.refresh (ZephAM_TeamworkSys.js:511)
at Window_Teamwork_Mentor.setActor (ZephAM_TeamworkSys.js:477)
at Scene_Teamwork.onActorOk (ZephAM_TeamworkSys.js:326)
Would love any help. Been banging my head against this for too long!