I'm trying to get some text to breifly appear, and then disappear, but I'm struggling to figure out how.
What I have here is some dialogue that is triggered if a boolean is true. It has 2 timer integers, one for each dialogue. While the first one is going, its related dialogue is displayed, until the timer reaches 100, which then stops, and the second timer gets going, showing its related dialogue and disappearing when that timer reaches 100.
if (bought == true){
this.shockTime1 = 0;
this.shockTime2 = 0;
if (this.shockTime1 < 100){
this.bubble.setAlpha(1);
this.speech.setText('What the heck?! \nYou used company\nmoney to buy some\nrun down mansion?\nWhy?!?');
this.shockTime1 = this.shockTime1 + 1;
}
else if (this.shockTime2 == 100 && this.shockTime2 < 100){
this.bubble.setAlpha(1);
this.speech.setText('Your not going to\neven live there! This is\nan outrageous waste\nof money! You \nlittle idiot!!!');
this.thankTime2 = this.thankTime2 + 1;
}
else {
this.bubble.setAlpha(0);
this.speech.setText('');
}
}
Or at least that's the idea. When I tested this, I found that the first timer only went up one and then stopped, thus leaving the first dialogue on display indefinitely. I'm not sure about what the solution could be, so I'm asking for help.
If this was in Java in the Eclipse compiler, I would use for loops to solve this issue. I did try to make what I thought would be a phaser version of a for loop, but I just got errors. If there is a way to do this with for loops, can someone give me an example.
If it helps, I'm using Phaser 3 in VSCode.