Greenmoonbase Posted October 3, 2018 Share Posted October 3, 2018 Is there a way to do line-height, letter-spacing, text-align:center in Phaser 3? Link to comment Share on other sites More sharing options...
blackhawx Posted October 3, 2018 Share Posted October 3, 2018 https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Text.html https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.Text.html#lineSpacing__anchor Not sure about the letter spacing, but here's a short demo var tconfig = { x: 200, y: 50, text: 'Some text to play with on my canvas', style: { fontSize: '24px', fontFamily: 'Arial', color: '#ffffff', align: 'center', lineSpacing: 44, } }; var text = this.make.text(tconfig); text.setWordWrapWidth(100, false); Greenmoonbase 1 Link to comment Share on other sites More sharing options...
Greenmoonbase Posted October 3, 2018 Author Share Posted October 3, 2018 Thank you! Working great! Link to comment Share on other sites More sharing options...
Greenmoonbase Posted October 14, 2018 Author Share Posted October 14, 2018 Looks like there's no letter spacing for text in Phaser 3 So here's a little solution if someone will need it textline = 'qwerty'; letterSpacing = 10; letter = null; startPositionX = 400; for(var i = 0; i < textline.length; i++){ if(!letter){ letter = this.add.text(startPositionX, 1020, textline[i]).setStyle({ fontSize: '60px' }); } else { letter = this.add.text(nextLetterX, 1020, textline[i]).setStyle({ fontSize: '60px' }); } nextLetterX = letter.x + letter.width + letterSpacing; } GreenCloversGuy and blackhawx 2 Link to comment Share on other sites More sharing options...
Recommended Posts