mirror of
https://github.com/wassname/phaser.git
synced 2026-07-29 11:24:31 +08:00
The entire Phaser library has been updated to match the new JSHint configuration.
This commit is contained in:
@@ -40,10 +40,10 @@ Phaser.Canvas = {
|
||||
* @param {HTMLElement} element - The targeted element that we want to retrieve the offset.
|
||||
* @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
|
||||
* @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
|
||||
*/
|
||||
*/
|
||||
getOffset: function (element, point) {
|
||||
|
||||
point = point || new Phaser.Point;
|
||||
point = point || new Phaser.Point();
|
||||
|
||||
var box = element.getBoundingClientRect();
|
||||
var clientTop = element.clientTop || document.body.clientTop || 0;
|
||||
@@ -64,7 +64,7 @@ Phaser.Canvas = {
|
||||
* @method Phaser.Canvas.getAspectRatio
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
|
||||
* @return {number} The ratio between canvas' width and height.
|
||||
*/
|
||||
*/
|
||||
getAspectRatio: function (canvas) {
|
||||
return canvas.width / canvas.height;
|
||||
},
|
||||
|
||||
@@ -387,7 +387,7 @@ Phaser.Device.prototype = {
|
||||
this.mobileSafari = true;
|
||||
} else if (/MSIE (\d+\.\d+);/.test(ua)) {
|
||||
this.ie = true;
|
||||
this.ieVersion = parseInt(RegExp.$1);
|
||||
this.ieVersion = parseInt(RegExp.$1, 10);
|
||||
} else if (/Midori/.test(ua)) {
|
||||
this.midori = true;
|
||||
} else if (/Opera/.test(ua)) {
|
||||
|
||||
+102
-102
@@ -12,146 +12,146 @@
|
||||
* @param {Phaser.Game} game - A reference to the currently running game.
|
||||
*/
|
||||
Phaser.RequestAnimationFrame = function(game) {
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - The currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - The currently running game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} isRunning - true if RequestAnimationFrame is running, otherwise false.
|
||||
* @default
|
||||
*/
|
||||
this.isRunning = false;
|
||||
/**
|
||||
* @property {boolean} isRunning - true if RequestAnimationFrame is running, otherwise false.
|
||||
* @default
|
||||
*/
|
||||
this.isRunning = false;
|
||||
|
||||
var vendors = [
|
||||
'ms',
|
||||
'moz',
|
||||
'webkit',
|
||||
'o'
|
||||
];
|
||||
var vendors = [
|
||||
'ms',
|
||||
'moz',
|
||||
'webkit',
|
||||
'o'
|
||||
];
|
||||
|
||||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
|
||||
{
|
||||
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
||||
}
|
||||
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++)
|
||||
{
|
||||
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @property {boolean} _isSetTimeOut - true if the browser is using setTimeout instead of raf.
|
||||
* @private
|
||||
*/
|
||||
this._isSetTimeOut = false;
|
||||
/**
|
||||
* @property {boolean} _isSetTimeOut - true if the browser is using setTimeout instead of raf.
|
||||
* @private
|
||||
*/
|
||||
this._isSetTimeOut = false;
|
||||
|
||||
/**
|
||||
* @property {function} _onLoop - The function called by the update.
|
||||
* @private
|
||||
*/
|
||||
this._onLoop = null;
|
||||
/**
|
||||
* @property {function} _onLoop - The function called by the update.
|
||||
* @private
|
||||
*/
|
||||
this._onLoop = null;
|
||||
|
||||
/**
|
||||
* @property {number} _timeOutID - The callback ID used when calling cancel.
|
||||
* @private
|
||||
*/
|
||||
this._timeOutID = null;
|
||||
/**
|
||||
* @property {number} _timeOutID - The callback ID used when calling cancel.
|
||||
* @private
|
||||
*/
|
||||
this._timeOutID = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.RequestAnimationFrame.prototype = {
|
||||
|
||||
/**
|
||||
* Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
|
||||
* @method Phaser.RequestAnimationFrame#start
|
||||
*/
|
||||
start: function () {
|
||||
/**
|
||||
* Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
|
||||
* @method Phaser.RequestAnimationFrame#start
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
this.isRunning = true;
|
||||
this.isRunning = true;
|
||||
|
||||
var _this = this;
|
||||
var _this = this;
|
||||
|
||||
if (!window.requestAnimationFrame)
|
||||
{
|
||||
this._isSetTimeOut = true;
|
||||
if (!window.requestAnimationFrame)
|
||||
{
|
||||
this._isSetTimeOut = true;
|
||||
|
||||
this._onLoop = function () {
|
||||
return _this.updateSetTimeout();
|
||||
};
|
||||
|
||||
this._timeOutID = window.setTimeout(this._onLoop, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._isSetTimeOut = false;
|
||||
this._timeOutID = window.setTimeout(this._onLoop, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._isSetTimeOut = false;
|
||||
|
||||
this._onLoop = function (time) {
|
||||
return _this.updateRAF(time);
|
||||
};
|
||||
|
||||
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
||||
}
|
||||
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* The update method for the requestAnimationFrame
|
||||
* @method Phaser.RequestAnimationFrame#updateRAF
|
||||
* @param {number} time - A timestamp, either from RAF or setTimeOut
|
||||
*/
|
||||
updateRAF: function (time) {
|
||||
/**
|
||||
* The update method for the requestAnimationFrame
|
||||
* @method Phaser.RequestAnimationFrame#updateRAF
|
||||
* @param {number} time - A timestamp, either from RAF or setTimeOut
|
||||
*/
|
||||
updateRAF: function (time) {
|
||||
|
||||
this.game.update(time);
|
||||
this.game.update(time);
|
||||
|
||||
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
||||
this._timeOutID = window.requestAnimationFrame(this._onLoop);
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* The update method for the setTimeout.
|
||||
* @method Phaser.RequestAnimationFrame#updateSetTimeout
|
||||
*/
|
||||
updateSetTimeout: function () {
|
||||
/**
|
||||
* The update method for the setTimeout.
|
||||
* @method Phaser.RequestAnimationFrame#updateSetTimeout
|
||||
*/
|
||||
updateSetTimeout: function () {
|
||||
|
||||
this.game.update(Date.now());
|
||||
this.game.update(Date.now());
|
||||
|
||||
this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall);
|
||||
this._timeOutID = window.setTimeout(this._onLoop, this.game.time.timeToCall);
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops the requestAnimationFrame from running.
|
||||
* @method Phaser.RequestAnimationFrame#stop
|
||||
*/
|
||||
stop: function () {
|
||||
/**
|
||||
* Stops the requestAnimationFrame from running.
|
||||
* @method Phaser.RequestAnimationFrame#stop
|
||||
*/
|
||||
stop: function () {
|
||||
|
||||
if (this._isSetTimeOut)
|
||||
{
|
||||
clearTimeout(this._timeOutID);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.cancelAnimationFrame(this._timeOutID);
|
||||
}
|
||||
if (this._isSetTimeOut)
|
||||
{
|
||||
clearTimeout(this._timeOutID);
|
||||
}
|
||||
else
|
||||
{
|
||||
window.cancelAnimationFrame(this._timeOutID);
|
||||
}
|
||||
|
||||
this.isRunning = false;
|
||||
this.isRunning = false;
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
/**
|
||||
* Is the browser using setTimeout?
|
||||
* @method Phaser.RequestAnimationFrame#isSetTimeOut
|
||||
* @return {boolean}
|
||||
*/
|
||||
isSetTimeOut: function () {
|
||||
return this._isSetTimeOut;
|
||||
},
|
||||
/**
|
||||
* Is the browser using setTimeout?
|
||||
* @method Phaser.RequestAnimationFrame#isSetTimeOut
|
||||
* @return {boolean}
|
||||
*/
|
||||
isSetTimeOut: function () {
|
||||
return this._isSetTimeOut;
|
||||
},
|
||||
|
||||
/**
|
||||
* Is the browser using requestAnimationFrame?
|
||||
* @method Phaser.RequestAnimationFrame#isRAF
|
||||
* @return {boolean}
|
||||
*/
|
||||
isRAF: function () {
|
||||
return (this._isSetTimeOut === false);
|
||||
}
|
||||
/**
|
||||
* Is the browser using requestAnimationFrame?
|
||||
* @method Phaser.RequestAnimationFrame#isRAF
|
||||
* @return {boolean}
|
||||
*/
|
||||
isRAF: function () {
|
||||
return (this._isSetTimeOut === false);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -73,7 +73,7 @@ Phaser.StageScaleMode = function (game, width, height) {
|
||||
* @property {boolean} forcePortrait - If the game should be forced to use Portrait mode, this is set to true by Game.Stage
|
||||
* @default
|
||||
*/
|
||||
this.forcePortrait = false;
|
||||
this.forcePortrait = false;
|
||||
|
||||
/**
|
||||
* @property {boolean} incorrectOrientation - If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.
|
||||
@@ -188,6 +188,11 @@ Phaser.StageScaleMode = function (game, width, height) {
|
||||
*/
|
||||
this.aspectRatio = 0;
|
||||
|
||||
/**
|
||||
* @property {any} event- The native browser events from full screen API changes.
|
||||
*/
|
||||
this.event = null;
|
||||
|
||||
var _this = this;
|
||||
|
||||
window.addEventListener('orientationchange', function (event) {
|
||||
@@ -209,7 +214,7 @@ Phaser.StageScaleMode = function (game, width, height) {
|
||||
document.addEventListener('fullscreenchange', function (event) {
|
||||
return _this.fullScreenChange(event);
|
||||
}, false);
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -301,6 +306,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
*/
|
||||
fullScreenChange: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (this.isFullScreen)
|
||||
{
|
||||
this.game.stage.canvas.style['width'] = '100%';
|
||||
@@ -429,6 +436,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
*/
|
||||
checkOrientation: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
this.orientation = window['orientation'];
|
||||
|
||||
if (this.isLandscape)
|
||||
@@ -454,6 +463,8 @@ Phaser.StageScaleMode.prototype = {
|
||||
*/
|
||||
checkResize: function (event) {
|
||||
|
||||
this.event = event;
|
||||
|
||||
if (window.outerWidth > window.outerHeight)
|
||||
{
|
||||
this.orientation = 90;
|
||||
@@ -526,7 +537,7 @@ Phaser.StageScaleMode.prototype = {
|
||||
force = false;
|
||||
}
|
||||
|
||||
if (this.game.device.iPad === false && this.game.device.webApp === false && this.game.device.desktop === false)
|
||||
if (this.game.device.iPad === false && this.game.device.webApp === false && this.game.device.desktop === false)
|
||||
{
|
||||
if (this.game.device.android && this.game.device.chrome === false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user