Phaser.BitmapText = function (game, x, y, font, text, size){ x = x || 0; y = y || 0; font = font || ''; text = text || ''; size = size || 32; this.game = game; this.exists = true ; this.name = ''; this.type = Phaser.BITMAPTEXT; this.z = 0; this.world = new Phaser.Point(x, y); this._text = text; this._font = font; this._fontSize = size; this._align = 'left'; this._tint = 16777215; this.events = new Phaser.Events(this); this.input = null ; this.cameraOffset = new Phaser.Point(); PIXI.BitmapText.call(this, text); this.position.set(x, y); this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0] ; } ; Phaser.BitmapText.prototype = Object.create(PIXI.BitmapText.prototype); Phaser.BitmapText.prototype.constructor = Phaser.BitmapText; Phaser.BitmapText.prototype.setStyle = function (){ this.style = { align: this._align} ; this.fontName = this._font; this.fontSize = this._fontSize; this.dirty = true ; } ; Phaser.BitmapText.prototype.preUpdate = function (){ this._cache[0] = this.world.x; this._cache[1] = this.world.y; this._cache[2] = this.rotation; if (!this.exists || !this.parent.exists) { this.renderOrderID = -1; return false ; } if (this.autoCull) { this.renderable = this.game.world.camera.screenView.intersects(this.getBounds()); } this.world.setTo(this.game.camera.x + this.worldTransform.tx, this.game.camera.y + this.worldTransform.ty); if (this.visible) { this._cache[3] = this.game.stage.currentRenderOrderID++ ; } return true ; } ; Phaser.BitmapText.prototype.update = function (){ } ; Phaser.BitmapText.prototype.postUpdate = function (){ if (this._cache[7] === 1) { this.position.x = (this.game.camera.view.x + this.cameraOffset.x) / this.game.camera.scale.x; this.position.y = (this.game.camera.view.y + this.cameraOffset.y) / this.game.camera.scale.y; } } ; Phaser.BitmapText.prototype.destroy = function (destroyChildren){ if (this.game === null || this.destroyPhase) { return ; } if (typeof destroyChildren === 'undefined') { destroyChildren = true ; } this._cache[8] = 1; if (this.parent) { if (this.parent instanceof Phaser.Group) { this.parent.remove(this); } else { this.parent.removeChild(this); } } var i = _AN_Read_length('length', this.children); if (destroyChildren) { while (i-- ){ if (this.children[i].destroy) { this.children[i].destroy(destroyChildren); } else { this.removeChild(this.children[i]); } } } else { while (i-- ){ this.removeChild(this.children[i]); } } this.exists = false ; this.visible = false ; this.filters = null ; this.mask = null ; this.game = null ; this._cache[8] = 0; } ; Object.defineProperty(Phaser.BitmapText.prototype, 'align', { get: function (){ return this._align; } , set: function (value){ if (value !== this._align) { this._align = value; this.setStyle(); } } } ); Object.defineProperty(Phaser.BitmapText.prototype, 'tint', { get: function (){ return this._tint; } , set: function (value){ if (value !== this._tint) { this._tint = value; this.dirty = true ; } } } ); Object.defineProperty(Phaser.BitmapText.prototype, 'angle', { get: function (){ return Phaser.Math.radToDeg(this.rotation); } , set: function (value){ this.rotation = Phaser.Math.degToRad(value); } } ); Object.defineProperty(Phaser.BitmapText.prototype, 'font', { get: function (){ return this._font; } , set: function (value){ if (value !== this._font) { this._font = value.trim(); this.style.font = this._fontSize + "px '" + this._font + "'"; this.dirty = true ; } } } ); Object.defineProperty(Phaser.BitmapText.prototype, 'fontSize', { get: function (){ return this._fontSize; } , set: function (value){ value = parseInt(value, 10); if (value !== this._fontSize) { this._fontSize = value; this.style.font = this._fontSize + "px '" + this._font + "'"; this.dirty = true ; } } } ); Object.defineProperty(Phaser.BitmapText.prototype, 'text', { get: function (){ return this._text; } , set: function (value){ if (value !== this._text) { this._text = value.toString() || ' '; this.dirty = true ; } } } ); Object.defineProperty(Phaser.BitmapText.prototype, "inputEnabled", { get: function (){ return (this.input && this.input.enabled); } , set: function (value){ if (value) { if (this.input === null ) { this.input = new Phaser.InputHandler(this); this.input.start(); } else if (this.input && !this.input.enabled) { this.input.start(); } } else { if (this.input && this.input.enabled) { this.input.stop(); } } } } ); Object.defineProperty(Phaser.BitmapText.prototype, "fixedToCamera", { get: function (){ return !!this._cache[7]; } , set: function (value){ if (value) { this._cache[7] = 1; this.cameraOffset.set(this.x, this.y); } else { this._cache[7] = 0; } } } ); Object.defineProperty(Phaser.BitmapText.prototype, "destroyPhase", { get: function (){ return !!this._cache[8]; } } );