dthrasher90 Posted April 12, 2017 Share Posted April 12, 2017 Is there a way to write text on to a sprite image... say for instance, if I wanted to write its name on the image? Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 12, 2017 Author Share Posted April 12, 2017 Nevermind, figured it out var spriteTextDT1 = game.add.text(DT1x, DT1y, 'DT1', {font: '12px'}); Link to comment Share on other sites More sharing options...
snowbillr Posted April 12, 2017 Share Posted April 12, 2017 If you want the text to automatically move with the sprite, you could always make a Phaser.Group and add both the sprite and text to that, so that they'd move as one. Link to comment Share on other sites More sharing options...
Kishore Posted April 13, 2017 Share Posted April 13, 2017 You can create a sprite and add the text-field as the child to sprite so that you manipulate a a single asset as @breed had mentioned. var sprite = game.add.sprite(200, 200, 'mushroom');var spriteTitle = game.add.text(0,0,'Title',{ font: "65px Arial", fill: "#ff0044", align: "center" }); sprite.addChild(sprite); webdva 1 Link to comment Share on other sites More sharing options...
snowbillr Posted April 13, 2017 Share Posted April 13, 2017 Ah gotcha. Didn't realize you could add a child to a sprite as well as a group. Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 13, 2017 Author Share Posted April 13, 2017 With the child added, I'm just assuming that it will follow the sprite? Also, can you make that text a variable? Link to comment Share on other sites More sharing options...
Kishore Posted May 20, 2019 Share Posted May 20, 2019 Hi @dthrasher90, I am sorry i am replying very late. but it might also help others. Yes that text field will be variable. Link to comment Share on other sites More sharing options...
Recommended Posts