RMMZ Back button in new Window_Base

nathanlink169

Game Dev by Career, no idea what I'm doing
Veteran
Joined
Aug 15, 2013
Messages
72
Reaction score
32
First Language
English
Primarily Uses
RMMV
Hi all,

I'm working through the new MZ codebase, and I figured I'd start from the beginning this time rather than trying to cobble together the advanced stuff first (which I probably should have done from the start when working with MV. Oops).

I've made a new class which inherits from Window_Base. I'm able to get the blank window to show up, but there is also a back button which appears in the top-left hand corner. This back button appears to have no functionality. Does anyone know how to pass it a method, and does anyone know how I may remove this back button, should I need to?

JavaScript:
function NP_Window_TestWindow() {
    this.initialize.apply(this, arguments);
}

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

NP_Window_TestWindow.prototype.initialize = function(rect, onClose) {
    Window_Base.prototype.initialize.call(this, rect);

    this._onClose = onClose;
}

NP_Window_TestWindow.prototype.destroy = function(options){
    Window_Base.prototype.destroy.call(this, options);

    this._onClose.call(this);
}
1599332762897.png
 

casper667

Casper Gaming
Veteran
Joined
Mar 15, 2012
Messages
231
Reaction score
318
First Language
English
Primarily Uses
RMMZ
The buttons are turned on/off by players in game with ConfigManager.touchUI (or the touch UI option in the in-game options menu). They are created mostly in Scene_MenuBase not the window. You can also redefine the needsXButton methods in any class that inherits from Scene_MenuBase (example: make a method in your scene called yourScene.prototype.needsCancelButton and have it return false). This would turn it off for just that scene rather than the whole game.

They are Sprite_Button and can support setClickHandler for methods that are called when they are clicked. If they don't have any methods passed to them, they call Input.virtualClick and Input handles it as the respective button (cancel for example is handled as if you hit the cancel button since it does not need any special methods). So if your window had a cancel handler, the cancel touch button would call that as it is interpreted as if you had pressed the cancel button on the keyboard/gamepad.
 
Last edited:

nathanlink169

Game Dev by Career, no idea what I'm doing
Veteran
Joined
Aug 15, 2013
Messages
72
Reaction score
32
First Language
English
Primarily Uses
RMMV
The buttons are turned on/off by players in game with ConfigManager.touchUI (or the touch UI option in the in-game options menu). They are created mostly in Scene_MenuBase not the window. You can also redefine the needsXButton methods in any class that inherits from Scene_MenuBase (example: make a method in your scene called yourScene.prototype.needsCancelButton and have it return false). This would turn it off for just that scene rather than the whole game.

They are Sprite_Button and can support setClickHandler for methods that are called when they are clicked. If they don't have any methods passed to them, they call Input.virtualClick and Input handles it as the respective button (cancel for example is handled as if you hit the cancel button since it does not need any special methods). So if your window had a cancel handler, the cancel touch button would call that as it is interpreted as if you had pressed the cancel button on the keyboard/gamepad.
Thanks Casper, that was exactly what I was looking for! For the benefit of anyone else coming across this in the future, here is the solution that I have now:

JavaScript:
NP_Scene_TestWindow.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this._cancelButton.setClickHandler(this.popScene.bind(this));
    this.createTestWindow();
}
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,018
Members
137,563
Latest member
MinyakaAeon
Top