hi guys
thanks for see that
i have one function in my scene that not in create()
that work is count down and minus my damage variable
when i called that function in update(), its count down by speed and my damage going to 0 by some seconds
i wanna to have timer for that action in my function
what should i do?
thanks a lot
I can solve that by using setTimeOut
Avoid setTimeout()
.
hi samme
my problem cant be fix by deleyedcall
because when one function call in update(), if use deleyedCall, after some seconds that function repreat infinity
but when i use setTimeout, after some seconds function call and for next loop we must wait some seconds for that function
same thats problem with addEvent
What’s your code now?
gorillaFight() {
if (this.o.ghost_mode) return;
this.o.ghost_mode = true;
setTimeout(() => {
this.o.ghost_mode = false;
}, 5000);
this.fightAudio.play();
this.damageText.setText("Damage: " + this.damage);
this.time.delayedCall(
5000,
function () {
this.damage -= 1;
},
[],
this
);
}
//update
update() {
this.gorillaFollows();
}
As long as you’re not calling delayedCall()
continuously, I think it should work as desired. There’s no difference with setTimeout()
in that regard.