Hi, first question here after spending months learning from existing topics. Thank you for all of the help so far!
I’m working on an RPG, kind of a mix of NES Zelda and FFIX on PS1. When my characters interact with objects and each other, I essentially want to have an on/off switch. Press spacebar, see the character talking, press spacebar again to make the speech disappear. A first and second curtain, to use a photography analogy.
To make my speech boxes appear and disappear, I made a speech box sprite, which follows my character (ale), and made separate animations for visible and invisible instances of the speech box. There is also a sprite that appears above characters to show that an interaction is possible (here, with a fir tree).
if (Phaser.Math.Distance.Between(this.ale.x, this.ale.y, this.fir1.x, this.fir1.y) < 19)
{
this.alealert.anims.play(‘alertvisible’, true);
this.signtalkframe.anims.play(‘signframeinvisible’, true);
if (Phaser.Input.Keyboard.JustDown(this.keyF)) {
console.log(‘F was pressed’);
this.signtalkframe.anims.play(‘signframevisible’, true);
this.alealert.anims.play(‘alertinvisible’, true);
}
}
If I use “isDown” rather than “JustDown”, I have to hold the key to keep the dialog box open, which doesn’t feel intuitive. But when I use “JustDown” the dialog box appears for a single frame, then hides again.
How do I press a key a single time and start an animation, and have the animation continue until I press the same key again? I don’t see any examples posted of “_startAnimation” and I’m guessing that might be the answer.
Cheers!