Phaser.Graphics = function (game, x, y){ x = x || 0; y = y || 0; this.game = game; this.exists = true ; this.name = ''; this.type = Phaser.GRAPHICS; this.z = 0; this.world = new Phaser.Point(x, y); this.cameraOffset = new Phaser.Point(); PIXI.Graphics.call(this); this.position.set(x, y); this._cache = [0, 0, 0, 0, 1, 0, 1, 0, 0] ; } ; Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype); Phaser.Graphics.prototype.constructor = Phaser.Graphics; Phaser.Graphics.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[2], this.game.camera.y + this.worldTransform[5]); if (this.visible) { this._cache[3] = this.game.stage.currentRenderOrderID++ ; } return true ; } ; Phaser.Graphics.prototype.update = function (){ } ; Phaser.Graphics.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.Graphics.prototype.destroy = function (destroyChildren){ if (this.game === null || this.destroyPhase) { return ; } if (typeof destroyChildren === 'undefined') { destroyChildren = true ; } this._cache[8] = 1; _AN_Call_clear('clear', this); 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-- ){ this.children[i].destroy(destroyChildren); } } else { while (i-- ){ this.removeChild(this.children[i]); } } this.exists = false ; this.visible = false ; this.game = null ; this._cache[8] = 0; } ; Phaser.Graphics.prototype.drawPolygon = function (poly){ this.moveTo(poly.points[0].x, poly.points[0].y); for (var i = 1; i < _AN_Read_length('length', poly.points); i += 1){ this.lineTo(poly.points[i].x, poly.points[i].y); } this.lineTo(poly.points[0].x, poly.points[0].y); } ; Object.defineProperty(Phaser.Graphics.prototype, 'angle', { get: function (){ return Phaser.Math.radToDeg(this.rotation); } , set: function (value){ this.rotation = Phaser.Math.degToRad(value); } } ); Object.defineProperty(Phaser.Graphics.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.Graphics.prototype, "destroyPhase", { get: function (){ return !!this._cache[8]; } } );