Hi guys, I'm currently trying to write my own HUD plugin (I know there are some already, but I kinda want to write as much myself as possible, for learning and license reasons).
The window I created is shown and updated as expected, except it is completely empty... I can't see why, because the string I hand over to the drawText function has the right text and it seems like it gets called correctly (on creation and everytime Scene_Map updates)
Here's what I have:
(function(){
var _map_create_all_windows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function(){
_map_create_all_windows.call(this);
this.createHUD();
}
Scene_Map.prototype.createHUD = function(){
this._hud = new Window_HUD();
this.addWindow(this._hud);
}
//-----------------------------------------------------------------------------
// Window_HUD
//
function Window_HUD(){
this.initialize.apply(this, arguments);
}
Window_HUD.prototype = Object.create(Window_Base.prototype);
Window_HUD.prototype.constructor = Window_HUD;
Window_HUD.prototype.initialize = function(){
Window_Base.prototype.initialize.call(this);
this.move(0, 0, Graphics.boxWidth, this.fittingHeight($gameParty.members().length));
this.drawContent();
};
Window_HUD.prototype.drawContent = function(){
for(var i = 0; i < $gameParty.members().length; ++i){
var name = $gameParty.members()._name;
var hp = $gameParty.members()._hp;
var maxHp = $gameParty.members().mhp;
var hudText = name + ": " + hp + "/" + maxHp;
this.drawText(hudText, 0, this.lineHeight() * i);
}
}
Window_HUD.prototype.update = function(){
this.move(0, 0, Graphics.boxWidth, this.fittingHeight($gameParty.members().length));
this.drawContent();
}
})();
Anyone has an idea, what I am doing wrong?
The window I created is shown and updated as expected, except it is completely empty... I can't see why, because the string I hand over to the drawText function has the right text and it seems like it gets called correctly (on creation and everytime Scene_Map updates)
Here's what I have:
(function(){
var _map_create_all_windows = Scene_Map.prototype.createAllWindows;
Scene_Map.prototype.createAllWindows = function(){
_map_create_all_windows.call(this);
this.createHUD();
}
Scene_Map.prototype.createHUD = function(){
this._hud = new Window_HUD();
this.addWindow(this._hud);
}
//-----------------------------------------------------------------------------
// Window_HUD
//
function Window_HUD(){
this.initialize.apply(this, arguments);
}
Window_HUD.prototype = Object.create(Window_Base.prototype);
Window_HUD.prototype.constructor = Window_HUD;
Window_HUD.prototype.initialize = function(){
Window_Base.prototype.initialize.call(this);
this.move(0, 0, Graphics.boxWidth, this.fittingHeight($gameParty.members().length));
this.drawContent();
};
Window_HUD.prototype.drawContent = function(){
for(var i = 0; i < $gameParty.members().length; ++i){
var name = $gameParty.members()._name;
var hp = $gameParty.members()._hp;
var maxHp = $gameParty.members().mhp;
var hudText = name + ": " + hp + "/" + maxHp;
this.drawText(hudText, 0, this.lineHeight() * i);
}
}
Window_HUD.prototype.update = function(){
this.move(0, 0, Graphics.boxWidth, this.fittingHeight($gameParty.members().length));
this.drawContent();
}
})();
Anyone has an idea, what I am doing wrong?