momenimum Posted July 25, 2018 Share Posted July 25, 2018 After I create a Text with properties, those properties are lost after I setText(). Let me know if I am doing something incorrectly. Thanks! //This gets centered this.label = new game.Text('SCORE 99999\nCongrats!',{align:'center'}); //No longer centered this.label.setText('SCORE '+score+'\nCongrats!'); Quote Link to comment Share on other sites More sharing options...
enpu Posted July 26, 2018 Share Posted July 26, 2018 I can't reproduce that one, are you doing anything else to the text other that calling setText? This code seem to work as expected: game.createScene('Main', { init: function() { this.text = new game.Text('This text is\ncentered', { align: 'center' }); this.text.addTo(this.stage); }, click: function() { this.text.setText('This text is still\ncentered'); } }); Quote Link to comment Share on other sites More sharing options...
momenimum Posted July 26, 2018 Author Share Posted July 26, 2018 Looks like its working. Maybe related to dev branch engine I recently switched to. Quote Link to comment Share on other sites More sharing options...
enpu Posted July 26, 2018 Share Posted July 26, 2018 That was tested on dev branch. So do you still have the issue? Quote Link to comment Share on other sites More sharing options...
momenimum Posted July 26, 2018 Author Share Posted July 26, 2018 It's working now thanks! Quote Link to comment Share on other sites More sharing options...
momenimum Posted July 28, 2018 Author Share Posted July 28, 2018 Hi @enpu please take a look at this sample, the setText() makes the text blank. I believe its related to maxWidth, because it works without maxWidth. game.addAsset('font.fnt'); game.createScene('Main', { init: function() { this.text = new game.Text("Hello Panda Banda!\nHow are you today?",{maxWidth:300}); this.text.addTo(this.stage); game.Timer.add(1500,function() {this.nextCall()}.bind(this)); }, nextCall: function() { this.text.setText("Line 1\nLine 2"); } }); Wolfsbane 1 Quote Link to comment Share on other sites More sharing options...
enpu Posted July 28, 2018 Share Posted July 28, 2018 Thanks, this should be fixed now! Btw, you are creating unnecessary function in your Time line: game.addAsset('font.fnt'); game.createScene('Main', { init: function() { this.text = new game.Text('Hello Panda Banda!\nHow are you today?', { maxWidth: 300 }); this.text.addTo(this.stage); game.Timer.add(1500, this.nextCall.bind(this)); }, nextCall: function() { this.text.setText('Line 1\nLine 2'); } }); Wolfsbane 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.