[RPGMMV] Window_MenuStatus Help (hp gauge)

Hi again!
I have a small problem with the window_menustatus and can't figure out yet how to fix it. I made new gauge bars for replace the default one, and they are working fine, but seem I cant animate all them. The code that draw the hp gauge bar is this (ignore the last line "push"):


Code:
Window_MenuStatus.prototype.drawHpGauge = function(index) {
        var actor = $gameParty.members()[index];
        this._HP_GAUGE = new TilingSprite(ImageManager.loadMenu(st_gauge_hp));
        var rect = this.itemRect(index);
        var x = rect.x;
        var y = 0;
        var width = Math.ceil((actor.hp * 176) / actor.mhp);
        this._HP_GAUGE.move(x + 42, y + 282, width, 14);
        this.addChild(this._HP_GAUGE);
        //_HPGauge.push(this._HP_GAUGE);   
};

This will draw a hp gauge for each character in party and is working. For animate it I just simply used a update like this:

Code:
Window_MenuStatus.prototype.update = function() {
    this._HP_GAUGE.origin.x += 1;
};

The animation work, BUT only for the last hp gauge that is draw, precisely the last party member in the party list.
I have try to use that push (the one I said to ignore) to send this._HP_GAUGE in a outside array and then set the update like this:

Code:
Window_MenuStatus.prototype.update = function() {
    for (i = 0; i < $gameParty.size(); i++) {
    this._HPGauge[i].origin.x += 1;
    };
};

Here the animation work for every character, but once hp drop below the max hp... the animation stop working (???).

I know another way to accomplish that and is working but that would involve a function with " this._HPGauge = []; for (i = 0; i < $gameParty.size(); i++) {code for the gauge and this._HPGauge.push(this._HP_GAUGE);}" and I find it drastic...

Thank you kindly for whoever reply and/or help!
No wonder it would work only for the lastgauge, since you have a line

this._HP_GAUGE = something;

and in the update function you only move that hp gauge.

By defining a new hp gauge you unassign the definition of the previous one, meaning that at the end the _HP_GAUGE is just the last gauge and will therefore be the only one moved.
So the drastic solution is necessary here.
Yep, that what I was thinking. So I had to go drastic XD (I don't know why I never liked the for () ...) but still I created a function for each different gauge (HP,MP, etc) with a "for" inside. I'm not sure if is correct way, I couldn't find better but the menu gauges are now working:

Code:
Window_MenuStatus.prototype.drawHpGauge = function() {   
    this._HPGauge = [];
    for (i = 0; i < $gameParty.size(); i++) {
        var actor = $gameParty.members()[i];
        this._HP_GAUGE = new TilingSprite(ImageManager.loadMenu(st_settings.gHP));
        var rect = this.itemRect(i);
        var x = rect.x;
        var y = 282;
        var width = Math.ceil((actor.hp * 176) / actor.mhp);
        // Gauge Background Image
        var _bottom = new Sprite(ImageManager.loadMenu(st_settings.gBackground));
        _bottom.x = x + 41;
        _bottom.y = y;
        this.addChildAt(_bottom, 3);
        // Gauge Image
        this._HP_GAUGE.move(x + 42, y, width, 14);
        this._HPGauge.push(this._HP_GAUGE);
        this.addChild(this._HP_GAUGE);
        // Gauge Top Image
        var _top = new Sprite(ImageManager.loadMenu(st_settings.gFrame));
        _top.x = x + 34;
        _top.y = y-1;
        this.addChild(_top);
    };
};

Window_MenuStatus.prototype.update = function() {
    for (i = 0; i < $gameParty.size(); i++) {
    this._HPGauge[i].origin.x += 1;
    this._MPGauge[i].origin.x += 1;
    this._EXPGauge[i].origin.x += 1;
    };
};

Tho I could improve the code probably. Maybe a single function for draw the background gauge and the frame in one single shot for all the gauges but I'm not sure.

Original thread: https://forums.rpgmakerweb.com/threads/rpgmmv-window_menustatus-help-hp-gauge.99576/