autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
58
Reaction score
38
First Language
English
Primarily Uses
RMMV
Hello,

A long while ago, I found out RPG MV games could be played with a controller and I thought, "Wow, that sounds really cool!" Then, I tried it out and found how limited that feature is. Well, I have managed to implement the d-pad, right joy stick, and joy stick button presses to do stuff on input.

My problem right now is trying to make the start menu properly close the menu.


This is my code to open the menu:

JavaScript:
var _sal.inputMapper.menuState = false;

var Alias_Scene_Map_updateMain = Scene_Map.prototype.updateMain;

Scene_Map.prototype.updateMain = function() {
    Alias_Scene_Map_updateMain.call(this);
    
    if (Input.isTriggered('startButton')) {
        if (_sal.inputMapper.menuState == false) { //open main menu
        _sal.inputMapper.menuState = true;
        var soundEffect_toplay = { name: "Skill3", volume: 100, pitch: 110, pan: 0};
        AudioManager.playSe(soundEffect_toplay);
        SceneManager.push(Scene_Menu);
        } else {
        _sal.inputMapper.menuState = false;
        SceneManager.pop();
      }
    } //end if 'startButton' pressed

}


Well, this works to open the menu. But, I want to be able to press the "start" button on the controller to close it. Since I am aliasing Scene_Map.prototype.update my close menu code doesn't seem to run when the menu is open.

Where should I put my code to close the menu, when the menu is already open?
 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
49
Reaction score
42
First Language
Português - BR
Primarily Uses
RMMZ
Yes, your code is not working because you are trying to exit the Menu via the Map scene. It turns out that the Map and the Menu are different scenes, they don't happen in parallel.

I haven't tested the code, but this should work:

JavaScript:
Scene_Menu.prototype.update = function() {
    Scene_Base.prototype.update.call(this);
    if (Input.isTriggered('startButton')) this.popScene();
};
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
58
Reaction score
38
First Language
English
Primarily Uses
RMMV
Thank you so much, it works!
Now, I can remap MV's default button to open the menu.

I'd like to keep this as compatible as possible. I see you didn't alias Scene_Menu.prototype.update().
Am I overwriting this function, or is it being created?
 

JorgeMaker

Veteran
Veteran
Joined
Jan 14, 2020
Messages
49
Reaction score
42
First Language
Português - BR
Primarily Uses
RMMZ
I didn't alias the update function of Scene_Menu, because originally it doesn't have any specific function other than what it inherits from the Scene_Base class.
But yes, you can make an alias for it if you are using or are going to use a plugin that adds new functions to the update method.

JavaScript:
(() => {
    var alias_Scene_Menu_update = Scene_Menu.prototype.update;
    Scene_Menu.prototype.update = function() {
        alias_Scene_Menu_update.call(this);
        if (Input.isTriggered('startButton')) this.popScene();
    };
})();
 

autodidact

Veteran
Veteran
Joined
Nov 13, 2020
Messages
58
Reaction score
38
First Language
English
Primarily Uses
RMMV
I see. I figured that was what was happening since I couldn't find an existing update method on Scene_Menu. But since I am still learning about how classes and inheritance work, I wanted to ask.

Thank you for teaching me, I feel like this little knowledge will take me quite aways.
 

Latest Threads

Latest Profile Posts

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!
I feel the need to inform everyone on the forums NOT to go with Web Hosting Canada for your hosting needs. It is by far the worst customer service and just overall experience I have ever had with hosting and I am Canadian...
BCj
Got another eye surgery monday. Hope I'll recover quick and all's well. A bit tired of surgeries. On a happy note, working on the next chapter of Escalia so hope I can continue soon :)
Celebrating the arrival of autumn in the Northern Hemisphere :)

Forum statistics

Threads
115,368
Messages
1,089,315
Members
150,057
Latest member
kotfwing
Top