Hi,
i have two scenes, in Scene1 the player can input his name and if ENTER is press the second scene should start. Everything works fine so far, but when i make new keyboard input in the second scene the input events from scene 1 are also fired.
scene 1 (from a lab example):
...
create(){
var self = this;
this.add.text(10, 10, 'Enter your name:', { font: '32px Courier', fill: '#ffffff' });
this.textEntry = this.add.text(10, 50, 'm', { font: '32px Courier', fill: '#ffff00' });
this.text = "";
this.input.keyboard.on('keydown',this.write,self);
}
write(event){
console.log("Key down in Scene 1");
if (event.keyCode === 8 && this.textEntry.text.length > 0)
{
this.textEntry.text = this.textEntry.text.substr(0, this.textEntry.text.length - 1);
}
else if (event.keyCode === 32 || (event.keyCode >= 48 && event.keyCode < 90))
{
this.text +=event.key;
}else if(event.keyCode === 13){
this.scene.start("PlayGame",{name:this.textEntry.text});
}
}
...
scene 2:
...
create(){
this.input.keyboard.on('keydown', function (event) {
console.log("Key down in Scene 2");
if (event.keyCode === 87)
{
console.log("Key W was pressed");
}
});
}
....