Size wordbubbles to text
This commit is contained in:
@@ -623,18 +623,18 @@ var moonlightDialog = {
|
|||||||
|
|
||||||
function stringSize(str, font)
|
function stringSize(str, font)
|
||||||
{
|
{
|
||||||
var f = font || '12px arial',
|
var widths = [];
|
||||||
o = $('<div>' + str + '</div>')
|
var height = 0;
|
||||||
.css({'position': 'absolute', 'float': 'left', 'visibility': 'hidden', 'font': f})
|
str.split("\n").forEach(function() {
|
||||||
.appendTo($('body')),
|
var f = font || '12px arial';
|
||||||
w = o.width(),
|
var o = $('<div>' + str + '</div>')
|
||||||
h = o.height();
|
.css({'position': 'absolute', 'float': 'left', 'visibility': 'hidden', 'font': f})
|
||||||
hstep = 0;
|
.appendTo($('body'));
|
||||||
newlines = Math.max(1, str.split("\n").length);
|
widths.push(o.width());
|
||||||
if ( newlines > 1 )
|
height += 5 + o.height();
|
||||||
hstep = 5;
|
}, this);
|
||||||
o.remove();
|
o.remove();
|
||||||
return [w/newlines, (h+hstep)*newlines];
|
return [Math.max(widths), 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