Jump to content

Text cropping


MoreK
 Share

Recommended Posts

Howdi!
I have just recently starting to learn Phaser and now I'm finalizing my new online game. I'm really impressed on what Phaser can do and the help I have found from this community has been really valuable.

 

Now, the question. I'm trying to implement text cropping and according to the documentation it should be straigh forward. However I can't make it work, maybe I'm missing something? I couldn't find any similar cases from earlier posts either.

 

This is basically what I'm trying to do:

function create() {    text = game.add.text(100, 100, 'Testin 1-2-3 Testing 1-2-3 Testing 1-2-3', {fontSize:18, fill: "#ffffff"});    var cropRect = new Phaser.Rectangle(0, 0, 100, 20);    text.crop(cropRect);    }

You can try it out in Phaser sandbox yourself, it shows a blank screen.

 

Any ideas?

 

Link to comment
Share on other sites

It may not be the perfect solution - but you could add a mask to your text component.

 

So draw your rectangle as before with the same x&y as your text then set  - text.mask = cropRect;

 

I'll take a look on this, thanks for the tip!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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