megumi014

Veteran
Veteran
Joined
Mar 8, 2017
Messages
130
Reaction score
213
First Language
Spanish
Primarily Uses
RMMV
Hiya!

As the title says: is there any way to disable a sprite button temporarily? (And activate it later?) Like with this._randomWindow.deactivate(); but for the mouse input?

I'm trying to set up a couple of windows on the Title Screen, and I could disable the mouse alltogether but I'd rather not.

I found this piece of code so I gueeess it's possible but I just can't find the necessary word. I tried with invisible but it didn't exist xD

Code:
Sprite_Button.prototype.processTouch = function() {
    if (this.isActive()) {
        if (TouchInput.isTriggered() && this.isButtonTouched()) {
            this._touching = true;
        }
        if (this._touching) {
            if (TouchInput.isReleased() || !this.isButtonTouched()) {
                this._touching = false;
                if (TouchInput.isReleased()) {
                    this.callClickHandler();
                }
            }
        }
    } else {
        this._touching = false;
    }
};

Sprite_Button.prototype.isActive = function() {
    var node = this;
    while (node) {
        if (!node.visible) {
            return false;
        }
        node = node.parent;
    }
    return true;
};
 

Trace

A Rieri Fan :3
Member
Joined
Jun 7, 2014
Messages
10
Reaction score
9
First Language
Indonesia
Primarily Uses
RMMV
Hey, you can create another this.isActive() function but for that specific function

Code:
Sprite_Button.prototype.processTouch = function() {
    if (this.isActive() && this.isTouchActive()) { /////add this//////
        if (TouchInput.isTriggered() && this.isButtonTouched()) {
            this._touching = true;
        }
        if (this._touching) {
            if (TouchInput.isReleased() || !this.isButtonTouched()) {
                this._touching = false;
                if (TouchInput.isReleased()) {
                    this.callClickHandler();
                }
            }
        }
    } else {
        this._touching = false;
    }
};

//don't need to edit this
Sprite_Button.prototype.isActive = function() {
    var node = this;
    while (node) {
        if (!node.visible) {
            return false;
        }
        node = node.parent;
    }
    return true;
};

//new function
Sprite_Button.prototype.isTouchActive = function() {
    return this._touchActive;
};

//new activate and deactivate function for touch
Sprite_Button.prototype.activateTouch = function() {
    this._touchActive = true;
};

Sprite_Button.prototype.deactivateTouch = function() {
    this._touchActive = false;
};

so whenever you call this.deactivateTouch, you'll disable the processTouch temporarily

Hope this helps...
:kaohi:
 

megumi014

Veteran
Veteran
Joined
Mar 8, 2017
Messages
130
Reaction score
213
First Language
Spanish
Primarily Uses
RMMV
Thank you! That makes so much sense :D I made a conditional check on the title screen that worked around the problem, but it's way more efficient to modify the Sprite Button function itself :kaoswt: Thanks again!
 

Latest Threads

Latest Profile Posts

dd_airport2.jpgdd_combat.jpg
dd_town.jpg
I did an experiment to try to solve the art style problem between RTP and 3D models.
But, it feels this grimdark world is going to end even faster. :kaoswt2:
Solovei wrote on caethyril's profile.
Hi, just wanted to say, thank you for helping me fix that event with the step count! I followed your example exactly and it works now:kaojoy:
still waiting for original character contest 3 bust/face dlc release :kaoluv:
Stimpaks and More.png
Continued work. Still a WIP, some need some retouching. Stimpak, Radaway, Psycho, Jet, Mentats, Medex(ish/needs to be purple), bloodpack, glowing bloodpack. Made some Nuka too. Need to make Rad-X.
Nuka Sheet WIP FR.png
Done translating our projects intro sequence : D

Forum statistics

Threads
111,183
Messages
1,059,060
Members
144,427
Latest member
AzureDragonSoul
Top