Size wordbubbles to text
This commit is contained in:
@@ -624,18 +624,19 @@ var moonlightDialog = {
|
|||||||
|
|
||||||
function stringSize(str, font)
|
function stringSize(str, font)
|
||||||
{
|
{
|
||||||
var widths = [];
|
var width = 0;
|
||||||
var height = 0;
|
var height = 0;
|
||||||
var f = font || '12px arial';
|
var f = font || '12px arial';
|
||||||
str.split("\n").forEach(function(x) {
|
str.split("\n").forEach(function(x) {
|
||||||
var o = $('<div>' + x + '</div>')
|
var o = $('<div>' + x + '</div>')
|
||||||
.css({'position': 'absolute', 'float': 'left', 'visibility': 'hidden', 'font': f})
|
.css({'position': 'absolute', 'float': 'left', 'visibility': 'hidden', 'font': f})
|
||||||
.appendTo($('body'));
|
.appendTo($('body'));
|
||||||
widths.push(o.width());
|
if ( o.width() > width )
|
||||||
|
width = o.width();
|
||||||
height += 5 + o.height();
|
height += 5 + o.height();
|
||||||
o.remove();
|
o.remove();
|
||||||
}, this);
|
}, this);
|
||||||
return [Math.max.call(widths), height];
|
return [width, height];
|
||||||
}
|
}
|
||||||
|
|
||||||
var EffectSprite = function(game, x, y, key, frame, animation) {
|
var EffectSprite = function(game, x, y, key, frame, animation) {
|
||||||
|
|||||||
Reference in New Issue
Block a user