sprite.alignIn with resizing text

Hi,

assume I have a container and want to align a text inside of that container, vertically centered and aligned at the right edge. As time flies by, the text can get bigger (currently not smaller) and the text should reset its position so that it will not cross the right edge of its container. So basically: if the text is getting wider, then the x position should get smaller so that all text stays inside the container.

I got
this.timeTxt = game.add.text(0, 0, ‘0’, {
fontSize : 32,
fill : “red”,
align: ‘right’,
boundsAlignH: ‘right’,
boundsAlignV: ‘middle’
});
this.timeTxt.alignIn(this.timeSprite, Phaser.RIGHT_CENTER, -this.timeTxt.width-10);
this.timeTxt.fixedToCamera = true;

and I have a function where I update the “this.timeTxt.text” property. The problem is, that assigning new values to x or whatever has no effect. Even if set fixedToCamera before changing to false and set it to true afterwards. I guess it’s the alignIn function. I also tested text.setBounds, but I’m running into scaling issues then. game.world.scale has such a huge impact. Although I rather would not use it, I’m forced to.

Not sure about what you want to do with camera and all but since you are aligning text to right you might want to set text’s anchor to (1, 0.5).

this.timeTxt.anchor.set(1, 0.5)

First I thought you didn’t understand me. Now, while implementing it, I recognize that I didn’t understand you (or the detailled effect of the anchor). Thanks for you help.