- Joined
- Nov 13, 2020
- Messages
- 82
- Reaction score
- 65
- First Language
- English
- Primarily Uses
- RMMV
Hello, I am trying to work on making multiple windows for a HUD display.
It works to display the windows and images, but only one of the windows will update (the last one).
I can't for the life of me figure out why only one of my windows will update when every other window in the map scene seems to update.
Of course, there is more code than I pasted below, but this refresh function seems to be the only problem. I have an "id" variable attached to every instance of a HUD_Window, but the console.log line shows that only the second window will run the refresh method. The first one never runs the refresh method.
I would love some help figuring this out.
EDIT: Okay, I feel a little better now. I entered the game menu and exited and the first window updated itself (though it is stuck until I reenter and exit the menu). It looks like I need to manually call an update method for this. But I don't know where and I don't know why since the second one updates perfectly fine.
I forgot some important code:
It works to display the windows and images, but only one of the windows will update (the last one).
I can't for the life of me figure out why only one of my windows will update when every other window in the map scene seems to update.
Of course, there is more code than I pasted below, but this refresh function seems to be the only problem. I have an "id" variable attached to every instance of a HUD_Window, but the console.log line shows that only the second window will run the refresh method. The first one never runs the refresh method.
I would love some help figuring this out.
JavaScript:
var smstart = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
smstart.apply(this, arguments);
this.arrayOfHUDs = [];
for (let i = 0; i < HUDwindowsArray.length; i++) {
var hw = new Hud_Window(i);
console.log(hw);
this.arrayOfHUDs.push(hw);
console.log(this.arrayOfHUDs.length+'i'+i);
this.addChild(this.arrayOfHUDs[i]);
}
Hud_Window.prototype.refresh = function() {
if (true) {
this.contents.clear();
console.log(this.hudID);
this.drawHUDicon(this.image_HUDicon, 0,0,32,32);
this.drawDamageImage($gameVariables.value(2), 1, 200, 200);
} //end if showing
else {
this.contents.clear();
}
}
EDIT: Okay, I feel a little better now. I entered the game menu and exited and the first window updated itself (though it is stuck until I reenter and exit the menu). It looks like I need to manually call an update method for this. But I don't know where and I don't know why since the second one updates perfectly fine.
I forgot some important code:
JavaScript:
//declare the new window class
function Hud_Window() {
this.initialize.apply(this, arguments);
referenceToMenu = this;
}
//Inherit from Window_Base and set constructor to Hud_Window (?the declaration of my class)
Hud_Window.prototype = Object.create(Window_Base.prototype);
Hud_Window.prototype.constructor = Hud_Window;
Hud_Window.prototype.initialize = function(hudnumber) {
Window.prototype.initialize.call(this);
...
}
Last edited: