Phaser.Text = function (game, x, y, text, style){ x = x || 0; y = y || 0; text = text || ''; style = style || ''; this.exists = true ; this.alive = true ; this.group = null ; this.name = ''; this.game = game; this._text = text; this._style = style; PIXI.Text.call(this, text, style); this.type = Phaser.TEXT; this.position.x = this.x = x; this.position.y = this.y = y; this.anchor = new Phaser.Point(); this.scale = new Phaser.Point(1, 1); this.scrollFactor = new Phaser.Point(1, 1); this._cache = { dirty: false , a00: 1, a01: 0, a02: x, a10: 0, a11: 1, a12: y, id: 1, x: -1, y: -1, scaleX: 1, scaleY: 1} ; this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); this.renderable = true ; } ; Phaser.Text.prototype = Object.create(PIXI.Text.prototype); Phaser.Text.prototype.constructor = Phaser.Text; Phaser.Text.prototype.update = function (){ if (!this.exists) { return ; } this._cache.dirty = false ; this._cache.x = this.x - (this.game.world.camera.x * this.scrollFactor.x); this._cache.y = this.y - (this.game.world.camera.y * this.scrollFactor.y); if (this.position.x != this._cache.x || this.position.y != this._cache.y) { this.position.x = this._cache.x; this.position.y = this._cache.y; this._cache.dirty = true ; } } ; Object.defineProperty(Phaser.Text.prototype, 'angle', { get: function (){ return Phaser.Math.radToDeg(this.rotation); } , set: function (value){ this.rotation = Phaser.Math.degToRad(value); } } ); Object.defineProperty(Phaser.Text.prototype, 'content', { get: function (){ return this._text; } , set: function (value){ if (value !== this._text) { this._text = value; this.setText(value); } } } ); Object.defineProperty(Phaser.Text.prototype, 'font', { get: function (){ return this._style; } , set: function (value){ if (value !== this._style) { this._style = value; this.setStyle(value); } } } );