Jump to content

Phaser 3 - Overlap + KeyDown


selelabala
 Share

Recommended Posts

Hello,

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;
this.text3anim.play('talk');
var musicConfig3 =
{
mute: false,
volume: 1,
rate: 1,
detune: 0,
seek: 0,
loop: false,
delay: 0
}
this.dialogueSound.play(musicConfig3);
}
 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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