Jump to content

How can add a label over sprite?


fran
 Share

Recommended Posts

Hello, I would like to know how to attach a label over character head, something like in the next image:

fred.jpg

 

 

I tried:
 

var style = { font: "30px Arial", fill: "#ffffff" };  
//this.label_score = this.game.add.text(20, 20, "0", style); <---- this one works on game screen
this.label_score = this.hello_sprite.add.text(20, 20, "0", style);

But it didn't worked. The label must follow the character on screen.

Thanks in advance.

Link to comment
Share on other sites

  • 2 years later...

Hi, just to clarify - is there really no way to add text to a sprite? It always had to be added to the game over?

I'm creating a game where the labels are over the characters' heads, but the characters are moving so every time I move the character I have to also move it's corresponding text field. It just seems more verbose and computationally expensive than adding text as a child of a sprite.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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