Skip to content

Commit b393aed

Browse files
committed
Fixed setPadding and padding value assignment
1 parent 025c9dc commit b393aed

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

  • v3/src/gameobjects/text/static

v3/src/gameobjects/text/static/Text.js

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ var Text = new Class({
176176
return this.style.setBackgroundColor(color);
177177
},
178178

179+
setFill: function (color)
180+
{
181+
return this.style.setFill(color);
182+
},
183+
179184
setColor: function (color)
180185
{
181186
return this.style.setColor(color);
@@ -269,8 +274,6 @@ var Text = new Class({
269274
this.padding.right = right;
270275
this.padding.bottom = bottom;
271276

272-
console.log(this.padding);
273-
274277
return this.updateText();
275278
},
276279

@@ -298,22 +301,30 @@ var Text = new Class({
298301

299302
var textSize = GetTextSize(this, size, lines);
300303

304+
var padding = this.padding;
305+
306+
var w = textSize.width + padding.left + padding.right;
307+
var h = textSize.height + padding.top + padding.bottom;
308+
309+
// console.log(textSize);
310+
// console.log(padding);
311+
// console.log(w, 'x', h);
312+
// console.log('');
313+
301314
if (!style.fixedWidth)
302315
{
303-
this.width = textSize.width;
316+
this.width = w;
304317
}
305318

306319
if (!style.fixedHeight)
307320
{
308-
this.height = textSize.height;
321+
this.height = h;
309322
}
310323

311324
this.updateDisplayOrigin();
312325

313-
var padding = this.padding;
314-
315-
var w = (textSize.width + padding.left + padding.right) * this.resolution;
316-
var h = (textSize.height + padding.top + padding.bottom) * this.resolution;
326+
w *= this.resolution;
327+
h *= this.resolution;
317328

318329
if (canvas.width !== w || canvas.height !== h)
319330
{

0 commit comments

Comments
 (0)