RMMV Displaying a window while the game is active?

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
274
Reaction score
161
First Language
Swedish
Primarily Uses
N/A
So the question is wheter or note the post name is possible. I know that you can add sprites and such.

But if I would like to have a window that displays in the top left constantly during play, is that doable? I would've tried but I am currently not at home, and if it's possible I'd just like to know where to start when I get back

best regards,
Bishiba
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,048
Reaction score
2,360
First Language
EN
Primarily Uses
RMMZ
Like a HUD? Yes, it's possible: create a new window instance and use the scene's addWindow method to add it to the scene~
 

bishiba

Adept
Veteran
Joined
Apr 6, 2016
Messages
274
Reaction score
161
First Language
Swedish
Primarily Uses
N/A
Like a HUD? Yes, it's possible: create a new window instance and use the scene's addWindow method to add it to the scene~
Alright, been trying to get this window to show. But I am getting the error:
1638458881073.png

It is pointing to this function:
JavaScript:
Scene_Base.prototype.addWindow = function(window) {
    this._windowLayer.addChild(window);
};
I don't understand why the Scene._windowLayer would be undefined?

And here is the function I am using, it doesn't have a feature, it's just me trying to get a window to show.
JavaScript:
Scene_Map.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this._transfer = $gamePlayer.isTransferring();
    var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId();
    DataManager.loadMapData(mapId);
    this.createMapWindow();
};

Scene_Map.prototype.createMapWindow = function() {
    var x = 44;
    var y = 22;
    var width = 66;
    var height = 400;
    this._mapWindow = new Window_MapWindow(x, y, width, height);
    this.addWindow(this._mapWindow);
};

function Window_MapWindow() {
    this.initialize.apply(this, arguments);
}

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

Window_MapWindow.prototype.initialize = function(x, y, width, height) {
    Window_Base.prototype.initialize.call(this, x, y, width, height);
    this._touching = false;
    this._enemy = null;
};


EDIT:
Changed the two functions in my code. Not getting the error, but I am not getting any window displayed.


JavaScript:
Scene_Map.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this._transfer = $gamePlayer.isTransferring();
    var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId();
    DataManager.loadMapData(mapId);
    this.createWindowLayer()
    this.createMapWindow();
};

Scene_Map.prototype.createMapWindow = function() {
    var x = 44;
    var y = 22;
    var width = 600;
    var height = 400;
    this._mapWindow = new Window_MapWindow(x, y, width, height);
    this.addWindow(this._mapWindow);
};
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,048
Reaction score
2,360
First Language
EN
Primarily Uses
RMMZ
It's because the window layer will generally not have been added by the end of the scene's create method. The scene creates its display objects only after the map data has loaded:
JavaScript:
Scene_Map.prototype.onMapLoaded = function() {
    if (this._transfer) {
        $gamePlayer.performTransfer();
    }
    this.createDisplayObjects();
};
Instead, you should patch the createDisplayObjects method, which gets called when the database has loaded. E.g.
JavaScript:
// Private scope to avoid naming clashes
(function() {
  // Store original method
  var _Scene_Map_createDisplayObjects = Scene_Map.prototype.createDisplayObjects;
  // Define override
  Scene_Map.prototype.createDisplayObjects = function() {
    // Invoke stored method
    _Scene_Map_createDisplayObjects.apply(this, arguments);
    // Run extra code
    this.createMapWindow();
  };
})();
Also, note that a patch/alias, like I've used here, usually lets you write less code than a full override and gives a better chance of compatibility with other plugins~

Edit: I didn't see your edit before, sorry. :kaoslp:
EDIT:
Changed the two functions in my code. Not getting the error, but I am not getting any window displayed.


JavaScript:
Scene_Map.prototype.create = function() {
    Scene_Base.prototype.create.call(this);
    this._transfer = $gamePlayer.isTransferring();
    var mapId = this._transfer ? $gamePlayer.newMapId() : $gameMap.mapId();
    DataManager.loadMapData(mapId);
    this.createWindowLayer()
    this.createMapWindow();
};
// snip //
The window layer is re-created when the map data loads, which is why this doesn't work. createDisplayObjects is the way to go! :kaohi:
 
Last edited:

Latest Threads

Latest Profile Posts

ScreenShot_1_3_2022_1_32_12.png
I feel QSprite for MV is underrated. I basically am able to use my chibi sideview battlers I drew on the maps and have all the motions available. this'll help a lot with cutscenes.
I've figured out how to reasonably tall-ify chibi sprites on my editor. I like that making tall sprites gives me control on expressing how tall characters seem on the field relative to each other as well as better differentiate adult sprites from child sprites.
doing some wacky experimental stuff in MV right now :kaoluv: I cannot wait to drop what I've been working on
Doing RPG Maker News for this week. (January 14th - 20th, 2022)

My brother keeps saying," Women in his story act crazy because women are crazy." That's one way to make sure that the only woman in his life will be the retirement caregiver nurse that has to change his bedpan.

Forum statistics

Threads
118,552
Messages
1,116,916
Members
155,592
Latest member
Demure_Hero
Top