Costa1337 Posted July 4, 2017 Share Posted July 4, 2017 Quote var self = this; //wee are now append a key listener to catch enter this.game.input.keyboard.addCallbacks(this.background, null, function(data) { if(data.keyCode != 13){ return; } if(!n.value.trim()){ //no value self.error("Please enter your nickname."); return; } USERNAME = CONFIG.guest_prefix + n.value.trim(); SOCKET.emit("room request", {name: USERNAME}); }, null); }, Every time I enter ingame my player gets duplicated in the room. How can I refuse that state from being active ir that input in phaser? Please help me i'm really not a javascript expert. Link to comment Share on other sites More sharing options...
squilibob Posted July 5, 2017 Share Posted July 5, 2017 You need to move the line SOCKET.emit("room request", {name: USERNAME}) outside of your keyboard listener or it will duplicate every time you press enter Link to comment Share on other sites More sharing options...
Recommended Posts