Jump to content

Phaser 3 - Overlap + KeyDown


Recommended Posts


In Phaser 3, I am building an RPG and I am trying to make the player talk to a different sprite when overlapping and pressing a key (such as spacebar for example).Like, in gameboy pokémon you can walk up to a sign or a person and press (A) to cause text to appear.

So far, I have a textbox animation appearing every time my player and the sprite collide, however, how can I do this such that the player ONLY talks to the sprite when overlapping AND pressing down the key. 

PS: For doing this, I just call a showTextBox function whenever player collides with sprite.

//in create() i have this:
var dialogue1 = this.physics.add.overlap(player, this.student2, this.messageBox3, null, this);
//outside of create()
messageBox3() {
this.text3anim.visible = true;
var musicConfig3 =
mute: false,
volume: 1,
rate: 1,
detune: 0,
seek: 0,
loop: false,
delay: 0
Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...