From 42ecf4af7ae8c1d6314855a0df58dd3f559cb2b2 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Tue, 27 Jun 2017 02:35:38 +0100 Subject: [PATCH] Fixed polyfill errors and added direction consts. --- v3/src/checksum.js | 2 +- v3/src/const.js | 8 +- v3/src/physics/impact/Body.js | 10 ++- v3/src/polyfills/Function.bind.js | 137 ------------------------------ 4 files changed, 17 insertions(+), 140 deletions(-) diff --git a/v3/src/checksum.js b/v3/src/checksum.js index 2f4ab60c7..75342c61a 100644 --- a/v3/src/checksum.js +++ b/v3/src/checksum.js @@ -1,4 +1,4 @@ var CHECKSUM = { -build: '234a6e20-5acf-11e7-94ea-914d156f6e97' +build: 'e3e6e2b0-5ad6-11e7-b604-99296cb8a42f' }; module.exports = CHECKSUM; \ No newline at end of file diff --git a/v3/src/const.js b/v3/src/const.js index 7d1ba5afc..f2730122b 100644 --- a/v3/src/const.js +++ b/v3/src/const.js @@ -5,7 +5,13 @@ var CONST = { AUTO: 0, CANVAS: 1, WEBGL: 2, - HEADLESS: 3 + HEADLESS: 3, + + NONE: 4, + UP: 5, + DOWN: 6, + LEFT: 7, + RIGHT: 8 }; diff --git a/v3/src/physics/impact/Body.js b/v3/src/physics/impact/Body.js index 24dc54e3a..2171ed776 100644 --- a/v3/src/physics/impact/Body.js +++ b/v3/src/physics/impact/Body.js @@ -76,7 +76,10 @@ var Body = new Class({ var res = this.world.collisionMap.trace(this.pos.x, this.pos.y, mx, my, this.size.x, this.size.y); - UpdateMotion(this, res); + if (this.handleMovementTrace(res)) + { + UpdateMotion(this, res); + } if (window.dumpit) { @@ -84,6 +87,11 @@ var Body = new Class({ } }, + handleMovementTrace: function (res) + { + return true; + }, + skipHash: function () { return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0)); diff --git a/v3/src/polyfills/Function.bind.js b/v3/src/polyfills/Function.bind.js index e1471ebf0..86276d04d 100644 --- a/v3/src/polyfills/Function.bind.js +++ b/v3/src/polyfills/Function.bind.js @@ -3,13 +3,6 @@ * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ -// ES6 Math.trunc - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc -if (!Math.trunc) { - Math.trunc = function trunc(x) { - return x < 0 ? Math.ceil(x) : Math.floor(x); - }; -} - /** * A polyfill for Function.prototype.bind */ @@ -52,133 +45,3 @@ if (!Function.prototype.bind) { })(); } -/** -* A polyfill for Array.isArray -*/ -if (!Array.isArray) -{ - Array.isArray = function (arg) - { - return Object.prototype.toString.call(arg) === '[object Array]'; - }; -} - -/** -* A polyfill for Array.forEach -* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach -*/ -if (!Array.prototype.forEach) -{ - Array.prototype.forEach = function(fun /*, thisArg */) - { - "use strict"; - - if (this === void 0 || this === null) - { - throw new TypeError(); - } - - var t = Object(this); - var len = t.length >>> 0; - - if (typeof fun !== "function") - { - throw new TypeError(); - } - - var thisArg = arguments.length >= 2 ? arguments[1] : void 0; - - for (var i = 0; i < len; i++) - { - if (i in t) - { - fun.call(thisArg, t[i], i, t); - } - } - }; -} - -/** -* Low-budget Float32Array knock-off, suitable for use with P2.js in IE9 -* Source: http://www.html5gamedevs.com/topic/5988-phaser-12-ie9/ -* Cameron Foale (http://www.kibibu.com) -*/ -if (typeof window.Uint32Array !== "function" && typeof window.Uint32Array !== "object") -{ - var CheapArray = function(type) - { - var proto = new Array(); // jshint ignore:line - - window[type] = function(arg) { - - if (typeof(arg) === "number") - { - Array.call(this, arg); - this.length = arg; - - for (var i = 0; i < this.length; i++) - { - this[i] = 0; - } - } - else - { - Array.call(this, arg.length); - - this.length = arg.length; - - for (var i = 0; i < this.length; i++) - { - this[i] = arg[i]; - } - } - }; - - window[type].prototype = proto; - window[type].constructor = window[type]; - }; - - CheapArray('Float32Array'); // jshint ignore:line - CheapArray('Uint32Array'); // jshint ignore:line - CheapArray('Uint16Array'); // jshint ignore:line - CheapArray('Int16Array'); // jshint ignore:line - CheapArray('ArrayBuffer'); // jshint ignore:line -} - -/** - * Also fix for the absent console in IE9 - */ -if (!window.console) -{ - window.console = {}; - window.console.log = window.console.assert = function(){}; - window.console.warn = window.console.assert = function(){}; -} - -/** - * performance.now - */ -(function(){ - - if ("performance" in window == false) { - window.performance = {}; - } - - Date.now = (Date.now || function () { // thanks IE8 - return new Date().getTime(); - }); - - if ("now" in window.performance == false) - { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart){ - nowOffset = performance.timing.navigationStart - } - - window.performance.now = function now(){ - return Date.now() - nowOffset; - } - } - -})();