diff --git a/README.md b/README.md index 9c5777625..e58de47e7 100644 --- a/README.md +++ b/README.md @@ -348,6 +348,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/ * PIXI.Rope and PIXI.Strip have been removed, and all functionality merged in to Phaser.Rope, to cut down on the number of internal classes and inheritance going on. * PIXI.Graphics and PIXI.GraphicsData have been removed, and all functionality merged in to Phaser.Graphics, to cut down on the number of internal classes and inheritance going on. * WebGLGraphics and CanvasGraphics have been updated so that it checks for Phaser Geometry shape types internally. +* PIXI.PI_2 has been removed, because it's available via Phaser.Math.PI2. The only place PI_2 was used has been updated to now use PI2. ### Bug Fixes @@ -375,6 +376,7 @@ Please note that Phaser uses a custom build of Pixi and always has done. The fol * PIXI.AbstractFilter has been removed as it's no longer used internally. All functionality is now available via Phaser.Filter. * PIXI.Strip and PIXI.Rope have been removed. All functionality is now available via Phaser.Rope. * PIXI.Graphics and PIXI.GraphicsData have been removed. All functionality is now available via Phaser.Graphics. The respective renderers have been updated. +* PIXI.PI_2, PIXI.RAD_TO_DEG and PIXI.DEG_TO_RAD have all been removed, as they are no longer used internally, and are all available under Phaser.Math. For changes in previous releases please see the extensive [Version History](https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md). diff --git a/src/core/Game.js b/src/core/Game.js index 860e9be45..0aec1ecf8 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -734,7 +734,7 @@ Phaser.Game.prototype = { } else if (window['console']) { - console.log('Phaser v' + v + ' | Pixi.js ' + PIXI.VERSION + ' | ' + r + ' | ' + a + ' | http://phaser.io'); + console.log('Phaser v' + v + ' | Pixi.js | ' + r + ' | ' + a + ' | http://phaser.io'); } }, diff --git a/src/gameobjects/RenderTexture.js b/src/gameobjects/RenderTexture.js index fb6f502b1..2ab688704 100644 --- a/src/gameobjects/RenderTexture.js +++ b/src/gameobjects/RenderTexture.js @@ -83,7 +83,7 @@ Phaser.RenderTexture = function (game, width, height, key, scaleMode, resolution */ this.renderer = renderer; - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { var gl = this.renderer.gl; this.baseTexture.textureIndex = textureUnit; @@ -136,7 +136,7 @@ Phaser.RenderTexture.prototype.renderXY = function (displayObject, x, y, clear) this._tempMatrix.tx = x; this._tempMatrix.ty = y; - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { this._renderWebGL(displayObject, this._tempMatrix, clear); } @@ -164,7 +164,7 @@ Phaser.RenderTexture.prototype.renderRawXY = function (displayObject, x, y, clea this._tempMatrix.identity().translate(x, y); - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { this._renderWebGL(displayObject, this._tempMatrix, clear); } @@ -201,7 +201,7 @@ Phaser.RenderTexture.prototype.render = function (displayObject, matrix, clear) this._tempMatrix.copyFrom(matrix); } - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { this._renderWebGL(displayObject, this._tempMatrix, clear); } @@ -240,7 +240,7 @@ Phaser.RenderTexture.prototype.resize = function (width, height, updateBase) { this.baseTexture.height = this.height * this.resolution; } - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { this.projection.x = this.width / 2; this.projection.y = -this.height / 2; @@ -267,7 +267,7 @@ Phaser.RenderTexture.prototype.clear = function () { return; } - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER, this.textureBuffer.frameBuffer); } @@ -416,7 +416,7 @@ Phaser.RenderTexture.prototype.getBase64 = function () { */ Phaser.RenderTexture.prototype.getCanvas = function () { - if (this.renderer.type === PIXI.WEBGL_RENDERER) + if (this.renderer.type === Phaser.WEBGL) { var gl = this.renderer.gl; var width = this.textureBuffer.width; diff --git a/src/math/Math.js b/src/math/Math.js index 3c1a839e2..2fc88343b 100644 --- a/src/math/Math.js +++ b/src/math/Math.js @@ -23,6 +23,44 @@ Phaser.Math = { */ PI2: Math.PI * 2, + /** + * Degrees to Radians factor. + * @property {number} Phaser.Math#DEG_TO_RAD + */ + DEG_TO_RAD: Math.PI / 180, + + /** + * Degrees to Radians factor. + * @property {number} Phaser.Math#RAD_TO_DEG + */ + RAD_TO_DEG: 180 / Math.PI, + + /** + * Convert degrees to radians. + * + * @method Phaser.Math#degToRad + * @param {number} degrees - Angle in degrees. + * @return {number} Angle in radians. + */ + degToRad: function (degrees) { + + return degrees * Phaser.Math.DEG_TO_RAD; + + }, + + /** + * Convert radians to degrees. + * + * @method Phaser.Math#radToDeg + * @param {number} radians - Angle in radians. + * @return {number} Angle in degrees + */ + radToDeg: function (radians) { + + return radians * Phaser.Math.RAD_TO_DEG; + + }, + /** * Given a number, this function returns the closest number that is a power of two. * This function is from the Starling Framework. @@ -1271,28 +1309,3 @@ Phaser.Math = { } }; - -var degreeToRadiansFactor = Math.PI / 180; -var radianToDegreesFactor = 180 / Math.PI; - -/** -* Convert degrees to radians. -* -* @method Phaser.Math#degToRad -* @param {number} degrees - Angle in degrees. -* @return {number} Angle in radians. -*/ -Phaser.Math.degToRad = function degToRad (degrees) { - return degrees * degreeToRadiansFactor; -}; - -/** -* Convert radians to degrees. -* -* @method Phaser.Math#radToDeg -* @param {number} radians - Angle in radians. -* @return {number} Angle in degrees -*/ -Phaser.Math.radToDeg = function radToDeg (radians) { - return radians * radianToDegreesFactor; -}; diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 2a5ddb15b..41a8721af 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -25,27 +25,6 @@ var PIXI = PIXI || {}; */ PIXI.game = null; -/** - * @property {Number} WEBGL_RENDERER - * @protected - * @static - */ -PIXI.WEBGL_RENDERER = 0; - -/** - * @property {Number} CANVAS_RENDERER - * @protected - * @static - */ -PIXI.CANVAS_RENDERER = 1; - -/** - * Version of pixi that is loaded. - * @property {String} VERSION - * @static - */ -PIXI.VERSION = "v2.2.9"; - // used to create uids for various pixi objects. PIXI._UID = 0; @@ -68,24 +47,6 @@ else PIXI.Uint16Array = Array; } -/** - * @property {Number} PI_2 - * @static - */ -PIXI.PI_2 = Math.PI * 2; - -/** - * @property {Number} RAD_TO_DEG - * @static - */ -PIXI.RAD_TO_DEG = 180 / Math.PI; - -/** - * @property {Number} DEG_TO_RAD - * @static - */ -PIXI.DEG_TO_RAD = Math.PI / 180; - /** * @property {String} RETINA_PREFIX * @protected diff --git a/src/pixi/display/DisplayObject.js b/src/pixi/display/DisplayObject.js index 60d39e037..27135e8f0 100644 --- a/src/pixi/display/DisplayObject.js +++ b/src/pixi/display/DisplayObject.js @@ -331,7 +331,7 @@ PIXI.DisplayObject.prototype = { var a, b, c, d, tx, ty; // so if rotation is between 0 then we can simplify the multiplication process.. - if (this.rotation % PIXI.PI_2) + if (this.rotation % Phaser.Math.PI_2) { // check to see if the rotation is the same as the previous render. This means we only need to use sin and cos when rotation actually changes if (this.rotation !== this.rotationCache) diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 47017dcf1..5cb63e1b0 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -28,7 +28,7 @@ PIXI.CanvasRenderer = function (game) { * @property type * @type Number */ - this.type = PIXI.CANVAS_RENDERER; + this.type = Phaser.CANVAS; /** * The resolution of the canvas. diff --git a/src/pixi/renderers/webgl/WebGLRenderer.js b/src/pixi/renderers/webgl/WebGLRenderer.js index c488934cf..36f640f4f 100644 --- a/src/pixi/renderers/webgl/WebGLRenderer.js +++ b/src/pixi/renderers/webgl/WebGLRenderer.js @@ -34,7 +34,7 @@ PIXI.WebGLRenderer = function(game) { * @property type * @type Number */ - this.type = PIXI.WEBGL_RENDERER; + this.type = Phaser.WEBGL; /** * The resolution of the renderer