Codenburger Posted March 1, 2015 Share Posted March 1, 2015 Hi, I have been trying to figure out how to update text on screen, which has come from user input that was stored in localStorage.Once the user name has been changed, I want the name on the screen to update. I have tried putting the text code inside the update: function() but this doesn't work.Please help..... Link to comment Share on other sites More sharing options...
CtlAltDel Posted March 1, 2015 Share Posted March 1, 2015 mytext.setText(somevar); // or mytext.setText('static text'); Link to comment Share on other sites More sharing options...
Codenburger Posted March 1, 2015 Author Share Posted March 1, 2015 Hi, Thank you,I can draw the text, no problem. It is when I come to update the text on screen, based on the localStorage value, where the text just stays the same until I reload the game. Then the text value changes. Link to comment Share on other sites More sharing options...
CtlAltDel Posted March 1, 2015 Share Posted March 1, 2015 If you console log the storage value is it the correct value? Or use a debugger. Link to comment Share on other sites More sharing options...
Codenburger Posted March 1, 2015 Author Share Posted March 1, 2015 The value is fine. I just can't update the text on screen. Link to comment Share on other sites More sharing options...
CtlAltDel Posted March 1, 2015 Share Posted March 1, 2015 If the value is fine just before you set it then it should work. Guess you need to dive into the debugger. Maybe a scoping problem with the localstorage value not being available in your update func? Link to comment Share on other sites More sharing options...
Codenburger Posted March 1, 2015 Author Share Posted March 1, 2015 If I alert(input.value) I can see the current value in the update function. The text object is in the update function also, but the text doesn't update every time, as I hoped. Link to comment Share on other sites More sharing options...
Codenburger Posted March 1, 2015 Author Share Posted March 1, 2015 I am new to Phaser, but learning quickly. The scope isn't a problem for using alert(), but must be for text. I think you may have hit on something there. I am away from my computer ATM, but will take a look soon. Thank you. I will reply when at PC. Link to comment Share on other sites More sharing options...
Recommended Posts