Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
83
Reaction score
102
First Language
English
Primarily Uses
RMMZ
I don't know how to update a value in window without it constantly drawing. I have a status effect system that kills the target after 10 turns(there's a way to remove the effect) and a timer appears above their heads letting the player know how many turns they have left.

If the current countdown is 5, I want it to say 5 and not 1098765 overlapped. I've tried clearing the rectangle, even destroying it but that doesn't prevent redrawing. The countdown to be drawn:

JavaScript:
CurseCountDownWindow.prototype.drawCountDown = function(actorId) {
    const actors = $gameParty.members()
    const actorIndex = actors.findIndex(members => members.actorId() === actorId)
    this.drawText(actors[actorIndex]._curseTurnCount, 0, 0, 48);
};

the countdown is iterated at the end of each turn process:
JavaScript:
BattleManager.processTurn = function() {

    const subject = this._subject;
    const action = subject.currentAction();
   
    if (subject.hasState(Curse.curseStatus) === true) {
       
        // Either was removed, yet to be applied or the application is in progress.
        if (subject._curseTurnCount === -1) {
            subject._hasCurse = true;
            subject._curseTurnCount = 10;
           
            // passed to the window's drawCountDown method for testing.
            Curse.cursedActorId = subject.actorId();
        };
       
        if (subject._hasCurse === true && subject._curseTurnCount > 0) {
            subject._curseTurnCount -= 1;

            // the count down in the window should be changed here to reflect turns
            // left til death.

            if (subject._curseTurnCount === 0) {
                Curse.cursedActorId = 0;
                subject._curseTurnCount = -1;
                subject._hasCurse = false;
                subject.die();
            };
        };
    };

    if (action) {
        action.prepare();
        if (action.isValid()) {
            this.startAction();
        }
        subject.removeCurrentAction();
    } else {
        this.endAction();
        this._subject = null;
    }
};
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
2,833
Reaction score
2,169
First Language
EN
Primarily Uses
RMMZ
You should clear [that area of] the bitmap before drawing. Here are a couple of options~
  1. Clear the entire bitmap:
    JavaScript:
    this.contents.clear();
    This is typically used in refresh methods: clear then redraw everything.

  2. Clear a rectangular area of the bitmap:
    JavaScript:
    this.contents.clearRect(x, y, width, height);
 

Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
83
Reaction score
102
First Language
English
Primarily Uses
RMMZ
Yes thank you. I tried the clearRect one earlier which didn't work as expected for some underlying reason, but clear() did the trick.
 

Latest Threads

Latest Posts

Latest Profile Posts

Finally got my website fixed and the security sorted so it's been a productive day. Can I go to sleep now? I mean... I don't need to work right?
It's always a good idea to refresh yourself on what your plugins do. I'm working on a map with opening walls, and I was about to tear my hair out over how much image editing and hand-constructing of autotiles I'd have to do, when I looked again and saw @Shaz 's Tile Changer could copy areas from another map.
"sorry it took me so long to respond" - can we please agree not to say that anymore unless it actually took a long time?! (Like 36hrs at least) I mean, I'm running out of funny responses here xD
Ugh... 4:53AM over here and I can't sleep so why not just game make.
I just love the MV feature that allows you to create your own animations!

Forum statistics

Threads
115,919
Messages
1,094,016
Members
151,174
Latest member
sardin
Top