Skip to content

Instantly share code, notes, and snippets.

@tarasn
Created June 29, 2014 13:59
Show Gist options
  • Save tarasn/c21d4e5a92bb85c670ad to your computer and use it in GitHub Desktop.
Save tarasn/c21d4e5a92bb85c670ad to your computer and use it in GitHub Desktop.
Place text on top of over images (sprites, buttons etc) tags: phaser
var sprite = game.add.sprite(0, 0, 'button');
var text = game.add.text(0, 0, "Some text", {font: "16px Arial", fill: "#ffffff"});
sprite.addChild(text);
// now text will be positioned relative to the sprite, and will move around with it like a group - except with sprites you can still use physics :)
@tarasn
Copy link
Author

tarasn commented Jun 29, 2014

@haffedali
Copy link

Haha thanks for this little file! Before I found this I was getting my sprite's position then centering my text over it haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment