joshcawthorne Posted January 14, 2017 Share Posted January 14, 2017 Hi all, I'm trying to create a coin counter in my game, using a bitmap font. Everything displays fine, and the counter works, however when a player collects a new coin, rather than replacing the '0' with a '1', it shows a '1', but underneath you can still see a '0' visibly. I've tried several work around methods, including even doing an if statement checking how many coins and replacing it with plain text rather than replying on the var count, and using coinText.updateText();. Does anyone have any ideas? I'll leave my code sample below. var crystalCount = 0; var coinText; //Skip down to the update section coinText = this.game.add.bitmapText(20, 10, 'carrier_command', "Crystals:" + crystalCount, 12); coinText.updateText(); Link to comment Share on other sites More sharing options...
XekeDeath Posted January 14, 2017 Share Posted January 14, 2017 It is because you are creating new objects over the top of the previous ones, not reusing the same object. In create, assign your coinText to a single instance of the bitmapText, and in the update, change the coinText.text property. joshcawthorne 1 Link to comment Share on other sites More sharing options...
joshcawthorne Posted January 14, 2017 Author Share Posted January 14, 2017 Oh, you're right! Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts