Yes I have. Which was what lead me to finding out about resize in the first place, since as you quite rightly said, there is no mention of it in the docs.
I have made some alterations since. Originally, I had one speech bubble that re-positioned/reset it's text each time the player entered a message.
Now for each new message, the old speech bubble is deleted and the new one created with what ever text is written
in player::update()
if(ig.input.pressed('enter'))
{
var settings = {vel:{x:0, y:0}};
var bubble;
if(ig.game.getEntitiesByType(EntityChatBox)[0])
{
bubble = ig.game.getEntitiesByType(EntityChatBox)[0];
bubble.bubbleTexture.reload();
ig.game.removeEntity(bubble);
bubble = 0;
}
if(ig.game.getEntitiesByType(EntityChatBox)[0])
{
alert("still there");
}
bubble = ig.game.spawnEntity(EntityChatBox, this.pos.x, this.pos.y, settings);
bubble.bubbleTexture.reload();
bubble.setup($(this.ta).val(),5);
//bubble.bubbleTexture.load();
$(this.ta).val("");
//this.msgTime.set(this.msgShowtime);
}
And, my ChatBox (speechbubble) functions.
init: function(x,y,settings)
{
this.parent(x,y,settings);
},
setup: function(text, time)
{
this.playerString = text;
this.msgTime.set(time);
if(this.msgFont.widthForString(this.playerString) > this.size.x)
{
var i = this.msgFont.widthForString(this.playerString) / this.size.x;
this.scale = Math.ceil(i);
this.bubbleTexture.resize(this.scale);
this.size.x = this.bubbleTexture.width * this.scale;
this.size.y = this.bubbleTexture.height * this.scale;
this.bubbleTexture.load();
}
},
update: function()
{
this.parent();
},
draw: function()
{
var player = ig.game.getEntitiesByType(EntityPlayer)[0];
this.pos.x = player.pos.x;
this.pos.y = player.pos.y - this.size.y;
this.parent();
this.bubbleTexture.draw(this.pos.x,
this.pos.y);
this.msgFont.draw(this.playerString,
player.pos.x + (this.size.x/2),
player.pos.y - (this.size.y/1.5),
ig.Font.ALIGN.CENTER);
if(this.msgTime.delta() > 0)
{
this.bubbleTexture.reload();
this.kill();
}
},
Doing it this way has appeared to stop the strange crop issue. However I think my maths for determining the scale is off.
Also, does anyone know a method of scaling in just one axis (x or y)? as opposed to customizing the current resize() function.