diff --git a/v3/src/checksum.js b/v3/src/checksum.js index d98c3be52..de4c3967d 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '37d7f8f0-091a-11e7-8491-f9d6d424c789' +build: '867d0fc0-09d0-11e7-a41f-615c7733ee76' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/components/Origin.js b/v3/src/components/Origin.js index f04e897b4..df181bc4e 100644 --- a/v3/src/components/Origin.js +++ b/v3/src/components/Origin.js @@ -3,24 +3,30 @@ var Origin = { - originX: 0, - originY: 0, + originX: 0.5, + originY: 0.5, + + // READ ONLY + displayOriginX: 0, + displayOriginY: 0, setOrigin: function (x, y) { - if (x === undefined) { x = 0; } + if (x === undefined) { x = 0.5; } if (y === undefined) { y = x; } this.originX = x; this.originY = y; + this.displayOriginX = x * this.width; + this.displayOriginY = y * this.height; + return this; }, setOriginToCenter: function () { - this.originX = this.frame.centerX; - this.originY = this.frame.centerY; + this.setOrigin(0.5); } }; diff --git a/v3/src/components/Texture.js b/v3/src/components/Texture.js index a3abc1600..97ef8a3e9 100644 --- a/v3/src/components/Texture.js +++ b/v3/src/components/Texture.js @@ -22,14 +22,14 @@ var Texture = { { this.renderFlags |= _FLAG; - if (this.hasOwnProperty('originX')) - { - // Default origin to the center - var w = Math.floor(this.frame.realWidth / 2); - var h = Math.floor(this.frame.realHeight / 2); + // if (this.hasOwnProperty('originX')) + // { + // // Default origin to the center + // var w = Math.floor(this.frame.realWidth / 2); + // var h = Math.floor(this.frame.realHeight / 2); - this.setOrigin(w, h); - } + // this.setOrigin(w, h); + // } } return this; diff --git a/v3/src/gameobjects/text/static/Text.js b/v3/src/gameobjects/text/static/Text.js index 90d071959..ef7a03255 100644 --- a/v3/src/gameobjects/text/static/Text.js +++ b/v3/src/gameobjects/text/static/Text.js @@ -16,7 +16,6 @@ var Text = new Class({ Components.GetBounds, Components.Origin, Components.ScaleMode, - Components.Size, Components.Transform, Components.Visible, TextRender @@ -46,7 +45,7 @@ var Text = new Class({ this.style = new TextStyle(this, style); - this.autoRound = false; + this.autoRound = true; /** * The Regular Expression that is used to split the text up into lines, in @@ -62,6 +61,9 @@ var Text = new Class({ this.padding = { x: 0, y: 0 }; + this.width = 1; + this.height = 1; + if (text !== '') { this.updateText(); @@ -88,6 +90,9 @@ var Text = new Class({ var textSize = GetTextSize(this, size, lines); + this.width = textSize.width; + this.height = textSize.height; + canvas.width = textSize.width * this.resolution; canvas.height = textSize.height * this.resolution; diff --git a/v3/src/gameobjects/text/static/TextCanvasRenderer.js b/v3/src/gameobjects/text/static/TextCanvasRenderer.js index 4a19d42e2..f85d11a50 100644 --- a/v3/src/gameobjects/text/static/TextCanvasRenderer.js +++ b/v3/src/gameobjects/text/static/TextCanvasRenderer.js @@ -27,8 +27,8 @@ var TextCanvasRenderer = function (renderer, src, interpolationPercentage, camer renderer.currentScaleMode = src.scaleMode; } - var dx = src.x - src.originX - camera.scrollX; - var dy = src.y - src.originY - camera.scrollY; + var dx = src.x - src.displayOriginX - camera.scrollX; + var dy = src.y - src.displayOriginY - camera.scrollY; var canvas = src.canvas; diff --git a/v3/src/renderer/canvas/utils/DrawImage.js b/v3/src/renderer/canvas/utils/DrawImage.js index 997406b4a..657110c6a 100644 --- a/v3/src/renderer/canvas/utils/DrawImage.js +++ b/v3/src/renderer/canvas/utils/DrawImage.js @@ -29,8 +29,8 @@ var DrawImage = function (src, camera) // ctx[this.smoothProperty] = (source.scaleMode === ScaleModes.LINEAR); } - var dx = frame.x - src.originX; - var dy = frame.y - src.originY; + var dx = frame.x - src.displayOriginX; + var dy = frame.y - src.displayOriginY; ctx.save(); ctx.translate(src.x - camera.scrollX, src.y - camera.scrollY); diff --git a/v3/src/renderer/webgl/batches/sprite/SpriteBatch.js b/v3/src/renderer/webgl/batches/sprite/SpriteBatch.js index 0754b25b5..28bc2e71a 100644 --- a/v3/src/renderer/webgl/batches/sprite/SpriteBatch.js +++ b/v3/src/renderer/webgl/batches/sprite/SpriteBatch.js @@ -197,8 +197,8 @@ SpriteBatch.prototype = { var scaleY = src.scaleY; var rotation = -src.rotation; var tempMatrixMatrix = tempMatrix.matrix; - var x = -src.originX + frame.x; - var y = -src.originY + frame.y; + var x = -src.displayOriginX + frame.x; + var y = -src.displayOriginY + frame.y; var xw = x + width; var yh = y + height; var cameraMatrix = camera.matrix.matrix;