MoreK Posted October 11, 2015 Share Posted October 11, 2015 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 More sharing options...
Skeptron Posted October 12, 2015 Share Posted October 12, 2015 The console displays : Uncaught TypeError: text.crop is not a function But the crop function is in the Text documentation... Weird... Doc : http://phaser.io/docs/2.4.3/Phaser.Text.html#crop Link to comment Share on other sites More sharing options...
oldmanvegas Posted October 12, 2015 Share Posted October 12, 2015 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; Link to comment Share on other sites More sharing options...
jmp909 Posted October 12, 2015 Share Posted October 12, 2015 phaser sandbox is 2.3.0 text crop wasn't introduced thenhttp://phaser.io/docs/2.3.0/Phaser.Text.html Skeptron 1 Link to comment Share on other sites More sharing options...
MoreK Posted October 12, 2015 Author Share Posted October 12, 2015 Oh, that explains the sandbox issue. I'm using Phaser 2.4.2 though, so it should work there. Hmmm.... need to dig deeper, unless someone has new ideas. Link to comment Share on other sites More sharing options...
MoreK Posted October 12, 2015 Author Share Posted October 12, 2015 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 More sharing options...
Recommended Posts