stone Posted May 20, 2014 Share Posted May 20, 2014 how to write on the sprite? Is there any API that can write? Link to comment Share on other sites More sharing options...
Zef Posted May 20, 2014 Share Posted May 20, 2014 What do you mean? Do you want to add text onto a sprite? Link to comment Share on other sites More sharing options...
stone Posted May 21, 2014 Author Share Posted May 21, 2014 What do you mean? Do you want to add text onto a sprite?Yes. Link to comment Share on other sites More sharing options...
j0hnskot Posted May 21, 2014 Share Posted May 21, 2014 I don't see something in the sprite class you could use directly. But you can always use the normal Text class . http://docs.phaser.io/Phaser.Text.html Link to comment Share on other sites More sharing options...
Heppell08 Posted May 21, 2014 Share Posted May 21, 2014 text = game.add.text(player.x, player.y - 10,'I am a sprite!);You'd have to create it in a way that it would be created at that point and then either deleted or the text is set in the update to keep the X/Y as the sprite moves. Link to comment Share on other sites More sharing options...
Zef Posted May 21, 2014 Share Posted May 21, 2014 Ok the best way to do this will be to add the text as a child of your sprite. Something like this: sprite = game.add.sprite(10, 10, 'mySprite');text = game.add.text(0,0, 'This is some text');sprite.addChild(text);By doing that the text will automatically move with the sprite, and is positioned relative to the sprites anchor too. Hope that helps lokhmakov 1 Link to comment Share on other sites More sharing options...
stone Posted May 22, 2014 Author Share Posted May 22, 2014 Great! This is what I want. Thanks!! Link to comment Share on other sites More sharing options...
Recommended Posts