[RPGMMV] Window_MenuStatus Help (hp gauge)

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
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!
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,125
Reaction score
10,640
First Language
Czech
Primarily Uses
RMMV
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.
 

Lady_Blackpearl

Villager
Member
Joined
May 25, 2018
Messages
27
Reaction score
15
First Language
Italian
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top