Ahuramazda

Veteran
Veteran
Joined
Nov 9, 2012
Messages
262
Reaction score
131
First Language
English
Primarily Uses
RMMZ
Back when MV came out I was able to port my HUD from VX Ace without much issue, but even getting a box to appear while on the map scene seems impossible for me this time around. I've tried various ideas and setups with no luck, so I'm wondering if someone can make a simple starter plugin so I can see the method now for creating a constant window on screen.

Literally all I need to get going is a window that appears on the map screen and I can do the rest but I don't think I understand how to create one with the updated MZ code. Below is where I have been attempting to start remaking it, but I'm getting an error at this point when I try testing and I don't know where to go from here if I'm even on the right track.
1598017664019.png

Code:
function HUD_Window() {
    this.initialize(...arguments);
}

HUD_Window.prototype = Object.create(Window_Base.prototype);
HUD_Window.prototype.constructor = HUD_Window;

HUD_Window.prototype.initialize = function(rect) {
    Window_Base.prototype.initialize.call(this, rect);
    this.opacity = 255;
    this.contentsOpacity = 255;
    this.refresh();
};

HUD_Window.prototype.refresh = function() {
    this.contents.clear();
    const width = Graphics.width
    this.drawBackground(0, 0, width, this.lineHeight());
    this.drawText("Testing?", 0, 0, width, "center");
};

HUD_Window.prototype.drawBackground = function(x, y, width, height) {
    const color1 = ColorManager.dimColor1();
    const color2 = ColorManager.dimColor2();
    const half = width / 2;
    this.contents.gradientFillRect(x, y, half, height, color2, color1);
    this.contents.gradientFillRect(x + half, y, half, height, color1, color2);
};

//////////////////////////////////////////////////////////////////////////////////
const alias_createAllWindows = Scene_Map.prototype.createAllWindows
Scene_Map.prototype.createAllWindows = function() {
    this.createHUD_Window();
};

Scene_Map.prototype.createHUD_Window = function() {
    const rect = this.HUD_WindowRect();
    this._HUD_Window = new HUD_Window(rect);
    this.addWindow(this._HUD_Window);
};

Scene_Map.prototype.HUD_WindowRect = function() {
    const wx = 200;
    const wy = 200;
    const ww = 300;
    const wh = 300
    return new Rectangle(wx, wy, ww, wh);
};
 

casper667

Casper Gaming
Veteran
Joined
Mar 15, 2012
Messages
325
Reaction score
442
First Language
English
Primarily Uses
RMMZ
Looks like it should work, but you forgot to call your alias for SceneMap.createAllWindows

JavaScript:
const alias_createAllWindows = Scene_Map.prototype.createAllWindows
Scene_Map.prototype.createAllWindows = function() {
    this.createHUD_Window();
};

should be


JavaScript:
const alias_createAllWindows = Scene_Map.prototype.createAllWindows
Scene_Map.prototype.createAllWindows = function() {
    alias_createAllWindows.call(this);
    this.createHUD_Window();
};

You are getting the error because by never calling the alias, the other windows are not being created and other functions in Scene_Map expect them to be created and are calling functions referencing them.
 

Ahuramazda

Veteran
Veteran
Joined
Nov 9, 2012
Messages
262
Reaction score
131
First Language
English
Primarily Uses
RMMZ
.............I cant believe that's what I was missing... I feel completely dumb now, lol

Thank you do much for taking the time to correct me on this and getting me moving on the right path!
 

Latest Profile Posts

Worked on a cutscene skip domino effect using Maker Systems' script as the basis. Basically if I have a batch of cutscenes in a row on different maps, now when you skip one cutscene it will skip the entire set. No more spamming X to skip a scene every new map.

Oh and it will work regardless of where you do it from in the set. Convenient!
seems absolutely WILD to me now all the hundreds of hours of work I used to do in 2k(3) over a decade ago with a resolution of 320x240. that seems so insanely TINY now, seemed so normal at the time!
Playing Aroma Indosiar theme song.
Aroma is an Indonesian TV show about cooking. :)
Working on a characteeer! (Why is it so hard to color hair?) ;-;
Silly-Sketches.png
Just finished eventing a couple simple puzzles in RMMV, for my very first game "Sample Quest." Just messing around, throwing things together, and calling it a story XD On a non-RM note, got my hair cut today!

Forum statistics

Threads
115,378
Messages
1,089,390
Members
150,075
Latest member
Bridge36000
Top