Effective way to pin Text into moving Physics objects?

Hi there

I want to add text into a sprite as character stats, so, if a sprite are moving, it’s text will be following the sprite position (pinned).

If sprite are destroyed, the connected text will be destroyed.

Is there are a built-in feature to do this?
or what effective way to do this?

Thank you!

UPDATE:

I just use this method, it’s work, and don’t know is a good method or not.

let sprite = this.physics.add.sprite( some parameters );
sprite.text = this.add.text( some parameters );

Then i can update position like this

sprite.text.setPosition(sprite.x, sprite.y);

Container, or phaser-plugin-follow.

1 Like