mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
Added scroll offset
This commit is contained in:
parent
da0ddeab54
commit
798ffa9c16
2 changed files with 40 additions and 2 deletions
|
@ -25,7 +25,6 @@ var DynamicBitmapText = new Class({
|
|||
function DynamicBitmapText (state, x, y, font, text, size, align)
|
||||
{
|
||||
if (text === undefined) { text = ''; }
|
||||
if (size === undefined) { size = 32; }
|
||||
if (align === undefined) { align = 'left'; }
|
||||
|
||||
GameObject.call(this, state, 'DynamicBitmapText');
|
||||
|
@ -34,7 +33,12 @@ var DynamicBitmapText = new Class({
|
|||
|
||||
this.text = text;
|
||||
|
||||
this.fontSize = size;
|
||||
this.fontSize = size || this.fontData.size;
|
||||
|
||||
this._scrollX = 0;
|
||||
this._scrollY = 0;
|
||||
this._maxWidth = 0;
|
||||
this._maxHeight = 0;
|
||||
|
||||
this.displayCallback;
|
||||
|
||||
|
@ -63,6 +67,34 @@ var DynamicBitmapText = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
setMaxWidth: function (value)
|
||||
{
|
||||
this._maxWidth = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
setMaxHeight: function (value)
|
||||
{
|
||||
this._maxHeight = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
setScrollX: function (value)
|
||||
{
|
||||
this._scrollX = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
setScrollY: function (value)
|
||||
{
|
||||
this._scrollY = value;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
// {
|
||||
// local: {
|
||||
// x,
|
||||
|
|
|
@ -70,6 +70,9 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc
|
|||
ctx.rotate(src.rotation);
|
||||
ctx.scale(src.scaleX, src.scaleY);
|
||||
|
||||
var currentX;
|
||||
var currentY;
|
||||
|
||||
for (var index = 0; index < textLength; ++index)
|
||||
{
|
||||
// Reset the scale (in case the callback changed it)
|
||||
|
@ -119,6 +122,9 @@ var DynamicBitmapTextCanvasRenderer = function (renderer, src, interpolationPerc
|
|||
rotation = output.rotation;
|
||||
}
|
||||
|
||||
// Scroll clipping
|
||||
x -= src._scrollX;
|
||||
|
||||
x *= scale;
|
||||
y *= scale;
|
||||
|
||||
|
|
Loading…
Reference in a new issue