Phaser.Graphics = function (game, x, y){ if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } this.type = Phaser.GRAPHICS; this.physicsType = Phaser.SPRITE; this.anchor = new Phaser.Point(); PIXI.DisplayObjectContainer.call(this); this.renderable = true ; this.fillAlpha = 1; this.lineWidth = 0; this.lineColor = 0; this.graphicsData = [] ; this.tint = 16777215; this.blendMode = PIXI.blendModes.NORMAL; this.currentPath = null ; this._webGL = [] ; this.isMask = false ; this.boundsPadding = 0; this._localBounds = new Phaser.Rectangle(0, 0, 1, 1); this.dirty = true ; this._boundsDirty = false ; this.webGLDirty = false ; this.cachedSpriteDirty = false ; Phaser.Component.Core.init.call(this, game, x, y, '', null ); } ; Phaser.Graphics.prototype = Object.create(PIXI.DisplayObjectContainer.prototype); Phaser.Graphics.prototype.constructor = Phaser.Graphics; Phaser.Component.Core.install.call(Phaser.Graphics.prototype, ['Angle', 'AutoCull', 'Bounds', 'Destroy', 'FixedToCamera', 'InputEnabled', 'InWorld', 'LifeSpan', 'PhysicsBody', 'Reset'] ); Phaser.Graphics.prototype.preUpdatePhysics = Phaser.Component.PhysicsBody.preUpdate; Phaser.Graphics.prototype.preUpdateLifeSpan = Phaser.Component.LifeSpan.preUpdate; Phaser.Graphics.prototype.preUpdateInWorld = Phaser.Component.InWorld.preUpdate; Phaser.Graphics.prototype.preUpdateCore = Phaser.Component.Core.preUpdate; Phaser.Graphics.prototype.preUpdate = function (){ if (!this.preUpdatePhysics() || !this.preUpdateLifeSpan() || !this.preUpdateInWorld()) { return false ; } return this.preUpdateCore(); } ; Phaser.Graphics.prototype.postUpdate = function (){ Phaser.Component.PhysicsBody.postUpdate.call(this); Phaser.Component.FixedToCamera.postUpdate.call(this); if (this._boundsDirty) { this.updateLocalBounds(); this._boundsDirty = false ; } for (var i = 0; i < _AN_Read_length('length', this.children); i++ ){ this.children[i].postUpdate(); } } ; Phaser.Graphics.prototype.destroy = function (destroyChildren){ _AN_Call_clear('clear', this); Phaser.Component.Destroy.prototype.destroy.call(this, destroyChildren); } ; Phaser.Graphics.prototype.drawTriangle = function (points, cull){ if (cull === undefined) { cull = false ; } var triangle = new Phaser.Polygon(points); if (cull) { var cameraToFace = new Phaser.Point(this.game.camera.x - points[0].x, this.game.camera.y - points[0].y); var ab = new Phaser.Point(points[1].x - points[0].x, points[1].y - points[0].y); var cb = new Phaser.Point(points[1].x - points[2].x, points[1].y - points[2].y); var faceNormal = cb.cross(ab); if (cameraToFace.dot(faceNormal) > 0) { this.drawPolygon(triangle); } } else { this.drawPolygon(triangle); } } ; Phaser.Graphics.prototype.drawTriangles = function (vertices, indices, cull){ if (cull === undefined) { cull = false ; } var point1 = new Phaser.Point(); var point2 = new Phaser.Point(); var point3 = new Phaser.Point(); var points = [] ; var i; if (!indices) { if (vertices[0] instanceof Phaser.Point) { for (i = 0; i < _AN_Read_length('length', vertices) / 3; i++ ){ this.drawTriangle([vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]] , cull); } } else { for (i = 0; i < _AN_Read_length('length', vertices) / 6; i++ ){ point1.x = vertices[i * 6 + 0]; point1.y = vertices[i * 6 + 1]; point2.x = vertices[i * 6 + 2]; point2.y = vertices[i * 6 + 3]; point3.x = vertices[i * 6 + 4]; point3.y = vertices[i * 6 + 5]; this.drawTriangle([point1, point2, point3] , cull); } } } else { if (vertices[0] instanceof Phaser.Point) { for (i = 0; i < _AN_Read_length('length', indices) / 3; i++ ){ points.push(vertices[indices[i * 3]]); points.push(vertices[indices[i * 3 + 1]]); points.push(vertices[indices[i * 3 + 2]]); if (_AN_Read_length('length', points) === 3) { this.drawTriangle(points, cull); points = [] ; } } } else { for (i = 0; i < _AN_Read_length('length', indices); i++ ){ point1.x = vertices[indices[i] * 2]; point1.y = vertices[indices[i] * 2 + 1]; points.push(point1.copyTo({ } )); if (_AN_Read_length('length', points) === 3) { this.drawTriangle(points, cull); points = [] ; } } } } } ; Phaser.Graphics.prototype.lineStyle = function (lineWidth, color, alpha){ this.lineWidth = lineWidth || 0; this.lineColor = color || 0; this.lineAlpha = (alpha === undefined)? 1: alpha; if (this.currentPath) { if (this.currentPath.shape.points.length) { this.drawShape(new Phaser.Polygon(this.currentPath.shape.points.slice(-2))); } else { this.currentPath.lineWidth = this.lineWidth; this.currentPath.lineColor = this.lineColor; this.currentPath.lineAlpha = this.lineAlpha; } } return this; } ; Phaser.Graphics.prototype.moveTo = function (x, y){ this.drawShape(new Phaser.Polygon([x, y] )); return this; } ; Phaser.Graphics.prototype.lineTo = function (x, y){ if (!this.currentPath) { this.moveTo(0, 0); } this.currentPath.shape.points.push(x, y); this.dirty = true ; this._boundsDirty = true ; return this; } ; Phaser.Graphics.prototype.quadraticCurveTo = function (cpX, cpY, toX, toY){ if (this.currentPath) { if (_AN_Read_length('length', this.currentPath.shape.points) === 0) { this.currentPath.shape.points = [0, 0] ; } } else { this.moveTo(0, 0); } var xa, ya, n = 20, points = this.currentPath.shape.points; if (_AN_Read_length('length', points) === 0) { this.moveTo(0, 0); } var fromX = points[_AN_Read_length('length', points) - 2]; var fromY = points[_AN_Read_length('length', points) - 1]; var j = 0; for (var i = 1; i <= n; ++i){ j = i / n; xa = fromX + ((cpX - fromX) * j); ya = fromY + ((cpY - fromY) * j); points.push(xa + (((cpX + ((toX - cpX) * j)) - xa) * j), ya + (((cpY + ((toY - cpY) * j)) - ya) * j)); } this.dirty = true ; this._boundsDirty = true ; return this; } ; Phaser.Graphics.prototype.bezierCurveTo = function (cpX, cpY, cpX2, cpY2, toX, toY){ if (this.currentPath) { if (_AN_Read_length('length', this.currentPath.shape.points) === 0) { this.currentPath.shape.points = [0, 0] ; } } else { this.moveTo(0, 0); } var n = 20, dt, dt2, dt3, t2, t3, points = this.currentPath.shape.points; var fromX = points[_AN_Read_length('length', points) - 2]; var fromY = points[_AN_Read_length('length', points) - 1]; var j = 0; for (var i = 1; i <= n; ++i){ j = i / n; dt = (1 - j); dt2 = dt * dt; dt3 = dt2 * dt; t2 = j * j; t3 = t2 * j; points.push(dt3 * fromX + 3 * dt2 * j * cpX + 3 * dt * t2 * cpX2 + t3 * toX, dt3 * fromY + 3 * dt2 * j * cpY + 3 * dt * t2 * cpY2 + t3 * toY); } this.dirty = true ; this._boundsDirty = true ; return this; } ; Phaser.Graphics.prototype.arcTo = function (x1, y1, x2, y2, radius){ if (this.currentPath) { if (_AN_Read_length('length', this.currentPath.shape.points) === 0) { this.currentPath.shape.points.push(x1, y1); } } else { this.moveTo(x1, y1); } var points = this.currentPath.shape.points, fromX = points[_AN_Read_length('length', points) - 2], fromY = points[_AN_Read_length('length', points) - 1], a1 = fromY - y1, b1 = fromX - x1, a2 = y2 - y1, b2 = x2 - x1, mm = Math.abs(a1 * b2 - b1 * a2); if (mm < 1e-08 || radius === 0) { if (points[_AN_Read_length('length', points) - 2] !== x1 || points[_AN_Read_length('length', points) - 1] !== y1) { points.push(x1, y1); } } else { var dd = a1 * a1 + b1 * b1, cc = a2 * a2 + b2 * b2, tt = a1 * a2 + b1 * b2, k1 = radius * Math.sqrt(dd) / mm, k2 = radius * Math.sqrt(cc) / mm, j1 = k1 * tt / dd, j2 = k2 * tt / cc, cx = k1 * b2 + k2 * b1, cy = k1 * a2 + k2 * a1, px = b1 * (k2 + j1), py = a1 * (k2 + j1), qx = b2 * (k1 + j2), qy = a2 * (k1 + j2), startAngle = Math.atan2(py - cy, px - cx), endAngle = Math.atan2(qy - cy, qx - cx); this.arc(cx + x1, cy + y1, radius, startAngle, endAngle, b1 * a2 > b2 * a1); } this.dirty = true ; this._boundsDirty = true ; return this; } ; Phaser.Graphics.prototype.arc = function (cx, cy, radius, startAngle, endAngle, anticlockwise, segments){ if (startAngle === endAngle) { return this; } if (anticlockwise === undefined) { anticlockwise = false ; } if (segments === undefined) { segments = 40; } if (!anticlockwise && endAngle <= startAngle) { endAngle += Math.PI * 2; } else if (anticlockwise && startAngle <= endAngle) { startAngle += Math.PI * 2; } var sweep = anticlockwise? (startAngle - endAngle) * -1: (endAngle - startAngle); var segs = Math.ceil(Math.abs(sweep) / (Math.PI * 2)) * segments; if (sweep === 0) { return this; } var startX = cx + Math.cos(startAngle) * radius; var startY = cy + Math.sin(startAngle) * radius; if (anticlockwise && this.filling) { this.moveTo(cx, cy); } else { this.moveTo(startX, startY); } var points = this.currentPath.shape.points; var theta = sweep / (segs * 2); var theta2 = theta * 2; var cTheta = Math.cos(theta); var sTheta = Math.sin(theta); var segMinus = segs - 1; var remainder = (segMinus % 1) / segMinus; for (var i = 0; i <= segMinus; i++ ){ var real = i + remainder * i; var angle = ((theta) + startAngle + (theta2 * real)); var c = Math.cos(angle); var s = - Math.sin(angle); points.push(((cTheta * c) + (sTheta * s)) * radius + cx, ((cTheta * - s) + (sTheta * c)) * radius + cy); } this.dirty = true ; this._boundsDirty = true ; return this; } ; Phaser.Graphics.prototype.beginFill = function (color, alpha){ this.filling = true ; this.fillColor = color || 0; this.fillAlpha = (alpha === undefined)? 1: alpha; if (this.currentPath) { if (_AN_Read_length('length', this.currentPath.shape.points) <= 2) { this.currentPath.fill = this.filling; this.currentPath.fillColor = this.fillColor; this.currentPath.fillAlpha = this.fillAlpha; } } return this; } ; Phaser.Graphics.prototype.endFill = function (){ this.filling = false ; this.fillColor = null ; this.fillAlpha = 1; return this; } ; Phaser.Graphics.prototype.drawRect = function (x, y, width, height){ this.drawShape(new Phaser.Rectangle(x, y, width, height)); return this; } ; Phaser.Graphics.prototype.drawRoundedRect = function (x, y, width, height, radius){ this.drawShape(new Phaser.RoundedRectangle(x, y, width, height, radius)); return this; } ; Phaser.Graphics.prototype.drawCircle = function (x, y, diameter){ this.drawShape(new Phaser.Circle(x, y, diameter)); return this; } ; Phaser.Graphics.prototype.drawEllipse = function (x, y, width, height){ this.drawShape(new Phaser.Ellipse(x, y, width, height)); return this; } ; Phaser.Graphics.prototype.drawPolygon = function (path){ if (path instanceof Phaser.Polygon) { path = path.points; } var points = path; if (!Array.isArray(points)) { points = new Array((_AN_Read_length('length', arguments))); for (var i = 0; i < _AN_Read_length('length', points); ++i){ points[i] = arguments[i]; } } this.drawShape(new Phaser.Polygon(points)); return this; } ; Phaser.Graphics.prototype.clear = function (){ this.lineWidth = 0; this.filling = false ; this.dirty = true ; this._boundsDirty = true ; this.clearDirty = true ; this.graphicsData = [] ; this.updateLocalBounds(); return this; } ; Phaser.Graphics.prototype.generateTexture = function (resolution, scaleMode, padding){ if (resolution === undefined) { resolution = 1; } if (scaleMode === undefined) { scaleMode = PIXI.scaleModes.DEFAULT; } if (padding === undefined) { padding = 0; } var bounds = this.getBounds(); bounds.width += padding; bounds.height += padding; var canvasBuffer = new PIXI.CanvasBuffer(bounds.width * resolution, bounds.height * resolution); var texture = PIXI.Texture.fromCanvas(canvasBuffer.canvas, scaleMode); texture.baseTexture.resolution = resolution; canvasBuffer.context.scale(resolution, resolution); canvasBuffer.context.translate(- bounds.x, - bounds.y); PIXI.CanvasGraphics.renderGraphics(this, canvasBuffer.context); return texture; } ; Phaser.Graphics.prototype._renderWebGL = function (renderSession){ if (this.visible === false || this.alpha === 0 || this.isMask === true ) { return ; } if (this._cacheAsBitmap) { if (this.dirty || this.cachedSpriteDirty) { this._generateCachedSprite(); this.updateCachedSpriteTexture(); this.cachedSpriteDirty = false ; this.dirty = false ; } this._cachedSprite.worldAlpha = this.worldAlpha; PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite, renderSession); return ; } else { renderSession.spriteBatch.stop(); renderSession.blendModeManager.setBlendMode(this.blendMode); if (this._mask) { renderSession.maskManager.pushMask(this._mask, renderSession); } if (this._filters) { renderSession.filterManager.pushFilter(this._filterBlock); } if (this.blendMode !== renderSession.spriteBatch.currentBlendMode) { renderSession.spriteBatch.currentBlendMode = this.blendMode; var blendModeWebGL = PIXI.blendModesWebGL[renderSession.spriteBatch.currentBlendMode]; renderSession.spriteBatch.gl.blendFunc(blendModeWebGL[0], blendModeWebGL[1]); } if (this.webGLDirty) { this.dirty = true ; this.webGLDirty = false ; } PIXI.WebGLGraphics.renderGraphics(this, renderSession); if (this.children.length) { renderSession.spriteBatch.start(); for (var i = 0; i < _AN_Read_length('length', this.children); i++ ){ this.children[i]._renderWebGL(renderSession); } renderSession.spriteBatch.stop(); } if (this._filters) { renderSession.filterManager.popFilter(); } if (this._mask) { renderSession.maskManager.popMask(this.mask, renderSession); } renderSession.drawCount++ ; renderSession.spriteBatch.start(); } } ; Phaser.Graphics.prototype._renderCanvas = function (renderSession){ if (this.visible === false || this.alpha === 0 || this.isMask === true ) { return ; } if (this._prevTint !== this.tint) { this.dirty = true ; this._prevTint = this.tint; } if (this._cacheAsBitmap) { if (this.dirty || this.cachedSpriteDirty) { this._generateCachedSprite(); this.updateCachedSpriteTexture(); this.cachedSpriteDirty = false ; this.dirty = false ; } this._cachedSprite.alpha = this.alpha; PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite, renderSession); return ; } else { var context = renderSession.context; var transform = this.worldTransform; if (this.blendMode !== renderSession.currentBlendMode) { renderSession.currentBlendMode = this.blendMode; context.globalCompositeOperation = PIXI.blendModesCanvas[renderSession.currentBlendMode]; } if (this._mask) { renderSession.maskManager.pushMask(this._mask, renderSession); } var resolution = renderSession.resolution; var tx = (transform.tx * renderSession.resolution) + renderSession.shakeX; var ty = (transform.ty * renderSession.resolution) + renderSession.shakeY; context.setTransform(transform.a * resolution, transform.b * resolution, transform.c * resolution, transform.d * resolution, tx, ty); PIXI.CanvasGraphics.renderGraphics(this, context); for (var i = 0; i < _AN_Read_length('length', this.children); i++ ){ this.children[i]._renderCanvas(renderSession); } if (this._mask) { renderSession.maskManager.popMask(renderSession); } } } ; Phaser.Graphics.prototype.getBounds = function (matrix){ if (this._currentBounds) { return this._currentBounds; } if (!this.renderable) { return Phaser.EmptyRectangle; } if (this.dirty) { this.updateLocalBounds(); this.webGLDirty = true ; this.cachedSpriteDirty = true ; this.dirty = false ; } var bounds = this._localBounds; var w0 = bounds.x; var w1 = bounds.width + bounds.x; var h0 = bounds.y; var h1 = bounds.height + bounds.y; var worldTransform = matrix || this.worldTransform; var a = worldTransform.a; var b = worldTransform.b; var c = worldTransform.c; var d = worldTransform.d; var tx = worldTransform.tx; var ty = worldTransform.ty; var x1 = a * w1 + c * h1 + tx; var y1 = d * h1 + b * w1 + ty; var x2 = a * w0 + c * h1 + tx; var y2 = d * h1 + b * w0 + ty; var x3 = a * w0 + c * h0 + tx; var y3 = d * h0 + b * w0 + ty; var x4 = a * w1 + c * h0 + tx; var y4 = d * h0 + b * w1 + ty; var maxX = x1; var maxY = y1; var minX = x1; var minY = y1; minX = x2 < minX? x2: minX; minX = x3 < minX? x3: minX; minX = x4 < minX? x4: minX; minY = y2 < minY? y2: minY; minY = y3 < minY? y3: minY; minY = y4 < minY? y4: minY; maxX = x2 > maxX? x2: maxX; maxX = x3 > maxX? x3: maxX; maxX = x4 > maxX? x4: maxX; maxY = y2 > maxY? y2: maxY; maxY = y3 > maxY? y3: maxY; maxY = y4 > maxY? y4: maxY; this._bounds.x = minX; this._bounds.width = maxX - minX; this._bounds.y = minY; this._bounds.height = maxY - minY; this._currentBounds = this._bounds; return this._currentBounds; } ; Phaser.Graphics.prototype.getLocalBounds = function (){ var matrixCache = this.worldTransform; this.worldTransform = Phaser.identityMatrix; for (var i = 0; i < _AN_Read_length('length', this.children); i++ ){ this.children[i].updateTransform(); } var bounds = this.getBounds(); this.worldTransform = matrixCache; for (i = 0; i < _AN_Read_length('length', this.children); i++ ){ this.children[i].updateTransform(); } return bounds; } ; Phaser.Graphics.prototype.containsPoint = function (point){ this.worldTransform.applyInverse(point, tempPoint); var graphicsData = this.graphicsData; for (var i = 0; i < _AN_Read_length('length', graphicsData); i++ ){ var data = graphicsData[i]; if (!data.fill) { continue ; } if (data.shape) { if (data.shape.contains(tempPoint.x, tempPoint.y)) { return true ; } } } return false ; } ; Phaser.Graphics.prototype.updateLocalBounds = function (){ var minX = Infinity; var maxX = - Infinity; var minY = Infinity; var maxY = - Infinity; if (this.graphicsData.length) { var shape, points, x, y, w, h; for (var i = 0; i < _AN_Read_length('length', this.graphicsData); i++ ){ var data = this.graphicsData[i]; var type = data.type; var lineWidth = data.lineWidth; shape = data.shape; if (type === Phaser.RECTANGLE || type === Phaser.ROUNDEDRECTANGLE) { x = shape.x - lineWidth / 2; y = shape.y - lineWidth / 2; w = shape.width + lineWidth; h = shape.height + lineWidth; minX = x < minX? x: minX; maxX = x + w > maxX? x + w: maxX; minY = y < minY? y: minY; maxY = y + h > maxY? y + h: maxY; } else if (type === Phaser.CIRCLE) { x = shape.x; y = shape.y; w = shape.radius + lineWidth / 2; h = shape.radius + lineWidth / 2; minX = x - w < minX? x - w: minX; maxX = x + w > maxX? x + w: maxX; minY = y - h < minY? y - h: minY; maxY = y + h > maxY? y + h: maxY; } else if (type === Phaser.ELLIPSE) { x = shape.x; y = shape.y; w = shape.width + lineWidth / 2; h = shape.height + lineWidth / 2; minX = x - w < minX? x - w: minX; maxX = x + w > maxX? x + w: maxX; minY = y - h < minY? y - h: minY; maxY = y + h > maxY? y + h: maxY; } else { points = shape.points; for (var j = 0; j < _AN_Read_length('length', points); j++ ){ if (points[j] instanceof Phaser.Point) { x = points[j].x; y = points[j].y; } else { x = points[j]; y = points[j + 1]; if (j < _AN_Read_length('length', points) - 1) { j++ ; } } minX = x - lineWidth < minX? x - lineWidth: minX; maxX = x + lineWidth > maxX? x + lineWidth: maxX; minY = y - lineWidth < minY? y - lineWidth: minY; maxY = y + lineWidth > maxY? y + lineWidth: maxY; } } } } else { minX = 0; maxX = 0; minY = 0; maxY = 0; } var padding = this.boundsPadding; this._localBounds.x = minX - padding; this._localBounds.width = (maxX - minX) + padding * 2; this._localBounds.y = minY - padding; this._localBounds.height = (maxY - minY) + padding * 2; } ; Phaser.Graphics.prototype._generateCachedSprite = function (){ var bounds = this.getLocalBounds(); if (!this._cachedSprite) { var canvasBuffer = new PIXI.CanvasBuffer(bounds.width, bounds.height); var texture = PIXI.Texture.fromCanvas(canvasBuffer.canvas); this._cachedSprite = new PIXI.Sprite(texture); this._cachedSprite.buffer = canvasBuffer; this._cachedSprite.worldTransform = this.worldTransform; } else { this._cachedSprite.buffer.resize(bounds.width, bounds.height); } this._cachedSprite.anchor.x = - (bounds.x / bounds.width); this._cachedSprite.anchor.y = - (bounds.y / bounds.height); this._cachedSprite.buffer.context.translate(- bounds.x, - bounds.y); this.worldAlpha = 1; PIXI.CanvasGraphics.renderGraphics(this, this._cachedSprite.buffer.context); this._cachedSprite.alpha = this.alpha; } ; Phaser.Graphics.prototype.updateCachedSpriteTexture = function (){ var cachedSprite = this._cachedSprite; var texture = cachedSprite.texture; var canvas = cachedSprite.buffer.canvas; texture.baseTexture.width = canvas.width; texture.baseTexture.height = canvas.height; texture.crop.width = texture.frame.width = canvas.width; texture.crop.height = texture.frame.height = canvas.height; cachedSprite._width = canvas.width; cachedSprite._height = canvas.height; texture.baseTexture.dirty(); } ; Phaser.Graphics.prototype.destroyCachedSprite = function (){ this._cachedSprite.texture.destroy(true ); this._cachedSprite = null ; } ; Phaser.Graphics.prototype.drawShape = function (shape){ if (this.currentPath) { if (_AN_Read_length('length', this.currentPath.shape.points) <= 2) { this.graphicsData.pop(); } } this.currentPath = null ; if (shape instanceof Phaser.Polygon) { shape = shape.clone(); shape.flatten(); } var data = new Phaser.GraphicsData(this.lineWidth, this.lineColor, this.lineAlpha, this.fillColor, this.fillAlpha, this.filling, shape); this.graphicsData.push(data); if (data.type === Phaser.POLYGON) { data.shape.closed = this.filling; this.currentPath = data; } this.dirty = true ; this._boundsDirty = true ; return data; } ; Phaser.Graphics.prototype.updateGraphicsTint = function (){ if (this.tint === 16777215) { return ; } var tintR = (this.tint >> 16 & 255) / 255; var tintG = (this.tint >> 8 & 255) / 255; var tintB = (this.tint & 255) / 255; for (var i = 0; i < _AN_Read_length('length', this.graphicsData); i++ ){ var data = this.graphicsData[i]; var fillColor = data.fillColor | 0; var lineColor = data.lineColor | 0; data._fillTint = (((fillColor >> 16 & 255) / 255 * tintR * 255 << 16) + ((fillColor >> 8 & 255) / 255 * tintG * 255 << 8) + (fillColor & 255) / 255 * tintB * 255); data._lineTint = (((lineColor >> 16 & 255) / 255 * tintR * 255 << 16) + ((lineColor >> 8 & 255) / 255 * tintG * 255 << 8) + (lineColor & 255) / 255 * tintB * 255); } } ; Object.defineProperty(Phaser.Graphics.prototype, 'cacheAsBitmap', { get: function (){ return this._cacheAsBitmap; } , set: function (value){ this._cacheAsBitmap = value; if (this._cacheAsBitmap) { this._generateCachedSprite(); } else { this.destroyCachedSprite(); } this.dirty = true ; this.webGLDirty = true ; } } );