Jump to content

Place text on top of over images (sprites, buttons etc)


samjarman
 Share

Recommended Posts

Hi!

 

I'd like to have some variable text on my buttons and I'd live to have some text on top of sprites that are subject to the arcade physics. Is there a nice way to tether text to a sprite or button? 

 

Maybe put them in the same group, but then can you put these groups into *other* groups? 

 

Cheers

 

 

 

Link to comment
Share on other sites

Yes you can put groups into groups into groups as far down as you want to. Handily Sprites can also have things added to them using sprite.addChild(text) - like so:

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 
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...