It has nothing to do with contents.clear() in the function, because if I remove it, the function will work
normally that means theres a relation of some kind. if it works without it and fails with it, theres some piece related to it that should be examined.
at Window_Base.get (rpg_core.js:6358)
this is why its always good to show the trace.
contents is a function call in and of itself for
_windowContentsSprite.bitmap. which means if
_windowContentsSprite is undefined, its exactly the error you'd get for doing anything with
contents. However, Windows at the lowest level initialize with that being null. so its a safe assumption that its being deleted by something after you create them.
If I do anything in regard to bitmaps (drawText, drawFace, contents.clear()) it fails and I can not understand why. I can also only draw on create, I tried passing to refresh and calling from create and it throws the same error.
you would have to show the entire plugin to share all your changes. because if youre using a "create" function to create the window, youre already working with something custom and theres too much unknown to say anything for certain.
For example, I dont know where that function is being called without seeing it. Scenes have a
create function thats used to create all of their needed windows and is called automatically when they start. I cant make the same assumption for a window. Thats normally the role of
initialize for them
Like, what am I missing? Is there a function to erase specific bitmaps or something that I'm not aware of?
No idea. what you had in the first post works just fine when you correct initialize's recursion, add in your refresh you last shared, and hook it up to the scene's update. All i did past that was set up the window to specifically show the party leader data for testing's sake
Spoiler
Code:
(function () {
var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
Scene_Map.prototype.createDisplayObjects = function () {
_Scene_Map_createDisplayObjects.apply(this, arguments);
this._myWindow = new Window_myWindow();
this.addChild(this._myWindow);
//this._myWindow.hide()
};
function Window_myWindow() {
this.initialize.apply(this, arguments);
}
Window_myWindow.prototype = Object.create(Window_Base.prototype);
Window_myWindow.prototype.constructor = Window_myWindow
Window_myWindow.prototype.initialize = function (x, y, width, height) {
Window_Base.prototype.initialize.call(this, 8, 8, 400, 178);
this.refresh();
}
Window_myWindow.prototype.refresh = function (faceImg, faceValue, name, gaugeValue) {
actor = $gameParty.members()[0]
faceImg = actor.faceName()
faceValue = 0;
name = actor.name()
gaugeValue = actor.hpRate()
this.drawFace(faceImg, faceValue, 0, 0, 144, 144);
this.drawTextEx('\\C[3]' + name, 144 + 18, 0, this.width - this.padding * 2, "left");
this.drawGauge(144 + 16, 20, 200, gaugeValue, this.hpGaugeColor1(), this.hpGaugeColor2());
this.drawTextEx('Attack', 144 + 18, 52, this.width - this.padding * 2, "left");
}
Window_myWindow.prototype.open = function () {
Window_Base.prototype.open.call(this);
this.refresh();
};
var alias = Scene_Map.prototype.update
Scene_Map.prototype.update = function () {
alias.call(this);
this._myWindow.refresh()
};
})();