[SOLVED] Text Element remains on Screen after Scene Change


I am trying to create a registration page for my game. Within my registration scene I am using the script InputR.js attached as a component to the group element GroupEM to allow text to be entered by a player within the field. Entering text into the field works. However, when I click on the “Main Menu” button to change from the registration scene to the main menu scene [script here] the text or perhaps the entire element generated by the input script is not destroyed on the scene change and can still be seen on the main menu scene. Image uploaded to demonstrate anomaly. Ideally, input into the text field will be stored in an internal variable which will be posted to a server and the text and/or group element will be destroyed on the scene change. Any help will be greatly appreciated.


I figured out the problem. Within the input script there is a function called onChange which if the storeValue boolean is checked will get the text field value and set it into local storage. The onChange function calls the getValue function which returns the this.element.value to set into local memory. onChange basically capture the element value when something changes, in this case a change of scene. I updated the code to simply set the this.element.value to “” which then allows it to reset [code below]. Now knowing how I can capture the text from the field I can now post it internally. I am unsure if others have found better ways to incorporate text fields into their games and then store that text but I believe this may be a promising start.

InputRL.prototype.onChange = function() {
        window.localStorage.setItem(this.entity._guid, this.getValue());
//check to see if value is what I typed
//change value back to empty
        this.element.value = "";
1 Like