hbkmad Posted January 19, 2015 Share Posted January 19, 2015 Hello, Is it possible to add in phaser a text field where the player would use the keyboard(mobile) to input text? Link to comment Share on other sites More sharing options...
efusien Posted April 16, 2015 Share Posted April 16, 2015 Same question. Looks like the Phaser example is not working on mobile: http://phaser.io/examples/v2/input/word-inputMaybe because the keyboard does not pop? Is it better to use a DOM input text and display it in the canvas?If someone has a best in class example... :-) Link to comment Share on other sites More sharing options...
ForgeableSum Posted April 16, 2015 Share Posted April 16, 2015 Of course. Create an input box in your HTML: <input type="text" name="fname" id="idofelement"> Then whenever you want to add the text to the game from the text in the input (ideally after a form submit event), you would do something like this:function addText() {var element = document.getElementById('idofelement');var inputText = element.value;var text = game.add.text(0,0,inputText); text.addColor('#ffff00', 0);}Heck you could even add the onChange event on the input element itself:<input type="text" name="fname" id="idofelement" onchange="addText()"> or if you are using jQuery:$('#idofelement').on('change',function() {addText()}); Link to comment Share on other sites More sharing options...
Recommended Posts