Draconar
Draconar

Reputation: 1195

Phaser.js: How to use Text as sprites

In my game numbers are game elements: they can be moved, touched, exploded and have their collision detected.

How can I turn text into sprites and/or physical bodies using Phaser.js?

Upvotes: 1

Views: 1176

Answers (2)

Kamen Minkov
Kamen Minkov

Reputation: 3712

A workaround would be to draw text inside a Phaser.BitmapData object and then make a sprite from it.

Example

Haven't used it that way, though, and it doesn't seem to work with zeroed values (or I'm missing something).

Upvotes: 1

Sky Walker
Sky Walker

Reputation: 1018

you cant because sprite and text are different node however you can attach text to empty sprite and when you move sprite the text will move same as collision you will just need to do it manually

enter image description here

Upvotes: 1

Related Questions