dthrasher90 Posted April 12, 2017 Report 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? Quote Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 12, 2017 Author Report Share Posted April 12, 2017 Nevermind, figured it out var spriteTextDT1 = game.add.text(DT1x, DT1y, 'DT1', {font: '12px'}); Quote Link to comment Share on other sites More sharing options...
snowbillr Posted April 12, 2017 Report 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. Quote Link to comment Share on other sites More sharing options...
Kishore Posted April 13, 2017 Report 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 Quote Link to comment Share on other sites More sharing options...
snowbillr Posted April 13, 2017 Report Share Posted April 13, 2017 Ah gotcha. Didn't realize you could add a child to a sprite as well as a group. Quote Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 13, 2017 Author Report 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? Quote Link to comment Share on other sites More sharing options...
Kishore Posted May 20, 2019 Report 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. 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.