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,837
Reaction score
2,176
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 Profile Posts

you know, some days you get resentful that game dev is even considered a "fun job" and other days it's like, welp, time to roll up my sleeves and code these molotov cocktails
If you suck at playing trumpets, that is probably why.
Been sick with a stomach virus for seven days now. Not going to work tomorrow because I'm still contagious according to my doctor.
Much as I love my job, I really hate playing "office politics". It would be nice if I didn't have to pretend to be someone else all day long.
I wanna get back into showing off Battlers and other assets I create again. But i'm always haunted by the "It's not good/realistic enough" voices that keep me from doing so.

Maybe I should get back to it, I did enjoy showing off whatever I came up with!

Forum statistics

Threads
115,958
Messages
1,094,384
Members
151,221
Latest member
yayayaayayay
Top