Arctica

Veteran
Veteran
Joined
Jul 19, 2021
Messages
83
Reaction score
100
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,829
Reaction score
2,164
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
100
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

So I just got my computer back (Was posting stuff on my phone) But now my dang monitor's broken! I'll need to get a new one, which means... JOBS! Yaaay... When I get a new monitor, I'll post picture of one of my RPGMMV projects.
Wish me luck... :kaodes:
Had to clean up disk space because Windows Updates was having my primaries' disk space for breakfast, lunch and dinner. I guess the clean up thingy doesn't work or something because there were 15gigs of old update files in it.
Monday morning, and the sudden message: Hey, can you set up a full second lesson about pixel art till tomorrow?
No one:
Steam game achievement: "Die 100 times in easy mode".

Forum statistics

Threads
115,889
Messages
1,093,733
Members
151,134
Latest member
umememe
Top