Lots more physics tests and updates.

PLEASE DO NOT upgrade to this release if you need your game working and it uses any of the physics functions, as they're nearly all broken here.
Just pushing up so I can share it with someone.
This commit is contained in:
photonstorm
2014-01-20 20:14:34 +00:00
parent 2532df8793
commit 128c7143d5
17 changed files with 1623 additions and 99 deletions
+1 -1
View File
@@ -217,7 +217,7 @@ Phaser.Stage.prototype = {
return;
}
if (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] === true || document['webkitHidden'] === true)
if (this.game.paused === false && (event.type == 'pagehide' || event.type == 'blur' || document['hidden'] === true || document['webkitHidden'] === true))
{
this.game.paused = true;
}
+1 -1
View File
@@ -100,7 +100,7 @@ Phaser.Text = function (game, x, y, text, style) {
/**
* @property {Phaser.Point} cameraOffset - If this object is fixed to the camera then use this Point to specify how far away from the Camera x/y it's rendered.
*/
this.cameraOffset = new Phaser.Point();
this.cameraOffset = new Phaser.Point(x, y);
/**
* @property {object} _cache - A mini cache for storing all of the calculated values.
+27
View File
@@ -30,6 +30,16 @@ Phaser.Input = function (game) {
* @default
*/
this.hitContext = null;
/**
* @property {function} moveCallback - An optional callback that will be fired every time the activePointer receives a move event from the DOM. Set to null to disable.
*/
this.moveCallback = null;
/**
* @property {object} moveCallbackContext - The context in which the moveCallback will be sent. Defaults to Phaser.Input but can be set to any valid JS object.
*/
this.moveCallbackContext = this;
};
@@ -404,6 +414,23 @@ Phaser.Input.prototype = {
this.mspointer.stop();
this.gamepad.stop();
this.moveCallback = null;
},
/**
* Sets a callback that is fired every time the activePointer receives a DOM move event such as a mousemove or touchmove.
* It will be called every time the activePointer moves, which in a multi-touch game can be a lot of times, so this is best
* to only use if you've limited input to a single pointer (i.e. mouse or touch)
* @method Phaser.Input#setMoveCallback
* @param {function} callback - The callback that will be called each time the activePointer receives a DOM move event.
* @param {object} callbackContext - The context in which the callback will be called.
*/
setMoveCallback: function (callback, callbackContext) {
this.moveCallback = callback;
this.moveCallbackContext = callbackContext;
},
/**
+7 -2
View File
@@ -257,7 +257,7 @@ Phaser.Pointer.prototype = {
},
/**
* Called internall by the Input Manager.
* Called by the Input Manager.
* @method Phaser.Pointer#update
*/
update: function () {
@@ -336,12 +336,17 @@ Phaser.Pointer.prototype = {
this.game.input.circle.y = this.game.input.y;
}
// If the game is paused we don't process any target objects
// If the game is paused we don't process any target objects or callbacks
if (this.game.paused)
{
return this;
}
if (this.game.input.moveCallback)
{
this.game.input.moveCallback.call(this.game.input.moveCallbackContext, this, this.x, this.y);
}
// Easy out if we're dragging something and it still exists
if (this.targetObject !== null && this.targetObject.isDragged === true)
{
+21 -2
View File
@@ -327,7 +327,7 @@ Phaser.Math = {
},
/**
* Find the angle of a segment from (x1, y1) -> (x2, y2 ).
* Find the angle of a segment from (x1, y1) -> (x2, y2).
* @method Phaser.Math#angleBetween
* @param {number} x1
* @param {number} y1
@@ -971,7 +971,7 @@ Phaser.Math = {
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @return {number} The distance between this Point object and the destination Point object.
* @return {number} The distance between the two sets of coordinates.
*/
distance: function (x1, y1, x2, y2) {
@@ -982,6 +982,25 @@ Phaser.Math = {
},
/**
* Returns the distance between the two given set of coordinates at the power given.
*
* @method Phaser.Math#distancePow
* @param {number} x1
* @param {number} y1
* @param {number} x2
* @param {number} y2
* @param {number} [pow=2]
* @return {number} The distance between the two sets of coordinates.
*/
distancePow: function (x1, y1, x2, y2, pow) {
if (typeof pow === 'undefined') { pow = 2; }
return Math.sqrt(Math.pow(x2 - x1, pow) + Math.pow(y2 - y1, pow));
},
/**
* Returns the rounded distance between the two given set of coordinates.
*
+86 -4
View File
@@ -310,14 +310,15 @@ Phaser.Physics.Arcade.prototype = {
/**
* Checks for collision between two game objects. You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions.
* If you'd like to collide an array of objects see Phaser.Physics.Arcade#collideArray.
* The objects are also automatically separated. If you don't require separation then use ArcadePhysics.overlap instead.
* An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place,
* giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped.
* The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called.
*
* @method Phaser.Physics.Arcade#collide
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object2 - The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap.
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object2 - The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap.
* @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them.
* @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them.
* @param {object} [callbackContext] - The context in which to run the callbacks.
@@ -332,6 +333,58 @@ Phaser.Physics.Arcade.prototype = {
this._result = false;
this._total = 0;
this.collideHandler(object1, object2, collideCallback, processCallback, callbackContext);
return (this._total > 0);
},
/**
* Checks for collision between a game object and an array of game objects. You can perform Sprite vs. Sprite, Sprite vs. Group, Group vs. Group, Sprite vs. Tilemap Layer or Group vs. Tilemap Layer collisions.
* The objects are also automatically separated. If you don't require separation then use ArcadePhysics.overlap instead.
* An optional processCallback can be provided. If given this function will be called when two sprites are found to be colliding. It is called before any separation takes place,
* giving you the chance to perform additional checks. If the function returns true then the collision and separation is carried out. If it returns false it is skipped.
* The collideCallback is an optional function that is only called if two sprites collide. If a processCallback has been set then it needs to return true for collideCallback to be called.
*
* @method Phaser.Physics.Arcade#collideArray
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap.
* @param {<Phaser.Sprite>array|<Phaser.Group>array|<Phaser.Particles.Emitter>array|<Phaser.Tilemap>array} objectArray - An array of objects to check. Can contain instances of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap.
* @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them.
* @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them.
* @param {object} [callbackContext] - The context in which to run the callbacks.
* @returns {boolean} True if a collision occured otherwise false.
*/
collideArray: function (object1, objectArray, collideCallback, processCallback, callbackContext) {
collideCallback = collideCallback || null;
processCallback = processCallback || null;
callbackContext = callbackContext || collideCallback;
this._result = false;
this._total = 0;
for (var i = 0, len = objectArray.length; i < len; i++)
{
this.collideHandler(object1, objectArray[i], collideCallback, processCallback, callbackContext);
}
return (this._total > 0);
},
/**
* Internal collision handler.
*
* @method Phaser.Physics.Arcade#collideHandler
* @private
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object1 - The first object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter, or Phaser.Tilemap.
* @param {Phaser.Sprite|Phaser.Group|Phaser.Particles.Emitter|Phaser.Tilemap} object2 - The second object to check. Can be an instance of Phaser.Sprite, Phaser.Group, Phaser.Particles.Emitter or Phaser.Tilemap. Can also be an array of objects to check.
* @param {function} [collideCallback=null] - An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them.
* @param {function} [processCallback=null] - A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then collision will only happen if processCallback returns true. The two objects will be passed to this function in the same order in which you specified them.
* @param {object} [callbackContext] - The context in which to run the callbacks.
*/
collideHandler: function (object1, object2, collideCallback, processCallback, callbackContext) {
// Only collide valid objects
if (object1 && object2 && object1.exists && object2.exists)
{
@@ -397,8 +450,6 @@ Phaser.Physics.Arcade.prototype = {
}
}
return (this._total > 0);
},
/**
@@ -595,6 +646,36 @@ Phaser.Physics.Arcade.prototype = {
return false;
}
var r = false;
if (body1.deltaX() === 0 && body2.deltaX() === 0)
{
// They overlap but neither of them are moving
body1.embedded = true;
body2.embedded = true;
}
else if (body1.deltaX() != 0 && body2.deltaX() === 0)
{
r = body1.separate(body2);
}
else if (body2.deltaX() != 0 && body1.deltaX() === 0)
{
r = body2.separate(body1);
}
else
{
// Dual motion thingy
r = body1.separate(body2);
}
return r;
// return body2.separate(body1);
/*
// We got this far, so the bodies overlap and our process was good, which means we can separate ...
this._overlap = 0;
@@ -900,6 +981,7 @@ Phaser.Physics.Arcade.prototype = {
}
return true;
*/
},
+234 -74
View File
@@ -137,7 +137,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
/**
* @property {number} minBounceVelocity - The minimum bounce velocity (could just be the bounce value?).
*/
this.minBounceVelocity = 0.5;
// this.minBounceVelocity = 0.5;
this._debug = 0;
@@ -151,6 +151,12 @@ Phaser.Physics.Arcade.Body = function (sprite) {
*/
this.bounce = new Phaser.Point();
/**
* @property {Phaser.Point} minVelocity - When a body rebounds off another the minVelocity is checked, if the new velocity is lower than the minVelocity the body is stopped.
* @default
*/
this.minVelocity = new Phaser.Point(20, 20);
/**
* @property {Phaser.Point} maxVelocity - The maximum velocity in pixels per second sq. that the Body can reach.
* @default
@@ -200,6 +206,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
* @property {object} touching - An object containing touching results.
*/
this.touching = { none: true, up: false, down: false, left: false, right: false };
this.touchingPoint = new Phaser.Point(this.x, this.y);
/**
* This object is populated with previous touching values from the bodies previous collision.
@@ -295,6 +302,7 @@ Phaser.Physics.Arcade.Body = function (sprite) {
* @property {object} blocked - An object containing on which faces this Body is blocked from moving, if any.
*/
this.blocked = { up: false, down: false, left: false, right: false };
this.blockedPoint = new Phaser.Point();
/**
* @property {number} _dx - Internal cache var.
@@ -360,14 +368,6 @@ Phaser.Physics.Arcade.Body.prototype = {
this.wasTouching.left = this.touching.left;
this.wasTouching.right = this.touching.right;
this.touching.none = true;
this.touching.up = false;
this.touching.down = false;
this.touching.left = false;
this.touching.right = false;
this.embedded = false;
this.screenX = (this.sprite.worldTransform[2] - (this.sprite.anchor.x * this.width)) + this.offset.x;
this.screenY = (this.sprite.worldTransform[5] - (this.sprite.anchor.y * this.height)) + this.offset.y;
@@ -375,18 +375,32 @@ Phaser.Physics.Arcade.Body.prototype = {
this.preY = (this.sprite.world.y - (this.sprite.anchor.y * this.height)) + this.offset.y;
this.preRotation = this.sprite.angle;
this.x = this.preX;
this.y = this.preY;
this.rotation = this.preRotation;
this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
// This all needs to move - because a body may start the preUpdate already touching something
// See if we can reduce this down?
this.blocked.up = false;
this.blocked.down = false;
this.blocked.left = false;
this.blocked.right = false;
this.embedded = false;
this.x = this.preX;
this.y = this.preY;
this.rotation = this.preRotation;
// if (this.deltaX() == 0 && (this.touchingPoint.x !== this.x || this.touchingPoint.y !== this.y))
// {
// console.log('touch reset', this.x, this.y, this.touchingPoint);
// this.touching.none = true;
// this.touching.up = false;
// this.touching.down = false;
// this.touching.left = false;
// this.touching.right = false;
// }
this.speed = Math.sqrt(this.velocity.x * this.velocity.x + this.velocity.y * this.velocity.y);
this.angle = Math.atan2(this.velocity.y, this.velocity.x);
this._debug++;
if (this.moves)
@@ -403,6 +417,44 @@ Phaser.Physics.Arcade.Body.prototype = {
},
/**
* Internal method used to check the Body against the World Bounds.
*
* @method Phaser.Physics.Arcade#checkWorldBounds
* @protected
*/
checkWorldBounds: function () {
if (this.x <= this.game.world.bounds.x)
{
this.overlapX = this.game.world.bounds.x - this.x;
this.blocked.left = true;
// console.log(this._debug, 'cwl', this.overlapX, this.x, this.game.world.bounds.x);
}
else if (this.right >= this.game.world.bounds.right)
{
this.overlapX = this.right - this.game.world.bounds.right;
this.blocked.right = true;
// console.log(this._debug, 'cwr', this.overlapX, this.x, this.game.world.bounds.x);
}
if (this.y <= this.game.world.bounds.y)
{
this.overlapY = this.game.world.bounds.y - this.y;
this.blocked.up = true;
// console.log(this._debug, 'cwu', this.overlapY, this.y, this.height, this.bottom, this.game.world.bounds.bottom);
}
else if (this.bottom >= this.game.world.bounds.bottom)
{
this.overlapY = this.bottom - this.game.world.bounds.bottom;
this.blocked.down = true;
// console.log(this._debug, 'cwd', this.overlapY, this.y, this.height, this.bottom, this.game.world.bounds.bottom);
}
this.blockedPoint.setTo(this.x, this.y);
},
/**
* Internal method.
*
@@ -438,7 +490,8 @@ Phaser.Physics.Arcade.Body.prototype = {
this._dx = this.game.time.physicsElapsed * (this.velocity.x + this.motionVelocity.x / 2);
if (this._dx > this.minBounceVelocity)
// if (this._dx > this.minBounceVelocity)
if (Math.abs(this.velocity.x) > this.minVelocity.x)
{
this.x += this._dx;
this.velocity.x += this.motionVelocity.x;
@@ -493,7 +546,8 @@ Phaser.Physics.Arcade.Body.prototype = {
this._dy = this.game.time.physicsElapsed * (this.velocity.y + this.motionVelocity.y / 2);
if (this._dy > this.minBounceVelocity)
// if (this._dy > this.minBounceVelocity)
if (Math.abs(this.velocity.y) > this.minVelocity.y)
{
this.y += this._dy;
this.velocity.y += this.motionVelocity.y;
@@ -516,7 +570,8 @@ Phaser.Physics.Arcade.Body.prototype = {
this._dy = this.game.time.physicsElapsed * (this.velocity.y + this.motionVelocity.y / 2);
if (this._dy < -this.minBounceVelocity)
// if (this._dy < -this.minBounceVelocity)
if (Math.abs(this.velocity.y) > this.minVelocity.y)
{
this.y += this._dy;
this.velocity.y += this.motionVelocity.y;
@@ -557,6 +612,145 @@ Phaser.Physics.Arcade.Body.prototype = {
},
// This body is the one that is checking against 'body'
separateX: function (body) {
// Doesn't matter if this is moving or not
console.log('--- separateX -----------------------------------------------------------------------------');
console.log(this.sprite.name, 'testing against', body.sprite.name);
console.log(this.sprite.name, 'moving left:', (this.deltaX() < 0), 'moving right:', (this.deltaX() > 0));
this.overlapX = 0;
if (this.x < body.x)
{
this.overlapX = this.right - body.x;
}
else
{
this.overlapX = body.right - this.x;
}
// There are 5 possible collisions taking place
// if (this.deltaX() === 0 && body.deltaX())
// if (this.deltaX() < 0 )
// if (this.deltaX() < 0 && this.allowCollision.left && body.allowCollision.right)
// This body is moving, the body it collided with is not
},
separate: function (body) {
console.log('-----------------------------------------------------------------------------');
console.log(this.sprite.name, 'testing against', body.sprite.name);
console.log(this.sprite.name, 'moving left:', (this.deltaX() < 0), 'moving right:', (this.deltaX() > 0));
this.overlapX = 0;
this.overlapY = 0;
if (this.deltaX() < 0 && this.allowCollision.left && body.allowCollision.right)
{
// LEFT (will create a negative overlapX value)
this.overlapX = this.x - body.right;
console.log(this.sprite.name, 'check left', body.right, this.overlapX);
}
else if (this.deltaX() > 0 && this.allowCollision.right && body.allowCollision.left)
{
// RIGHT (will create a positive overlapX value)
this.overlapX = this.right - body.x;
console.log(this.sprite.name, 'check right', this.overlapX);
}
if (this.deltaY() < 0 && this.allowCollision.up && body.allowCollision.down)
{
// UP (will create a negative overlapY value)
this.overlapY = this.y - body.bottom;
}
else if (this.deltaY() > 0 && this.allowCollision.down && body.allowCollision.up)
{
// DOWN
this.overlapY = this.bottom - body.y;
}
if (this.overlapX === 0 && this.overlapY === 0)
{
return false;
}
else
{
this.overlapHandler(this.overlapX, this.overlapY, body);
body.overlapHandler(this.overlapX, this.overlapY, this);
return true;
}
},
overlapHandler: function (x, y, body) {
if (x !== 0)
{
// Both moving, so let's cut the overlap in half
if (this.deltaX() != 0 && body.deltaX() != 0)
{
console.log(this.sprite.name, 'both overlap, halving');
x * 0.5;
}
if (this.deltaX() !== 0)
{
// Not moving, caught impact from another object
}
else
{
}
if (this.deltaX() < 0 && !this.blocked.right)
{
// This body is moving left
this.x += x;
console.log(this.sprite.name, 'touch h-left', this.x, x);
}
else if (this.deltaX() > 0 && !this.body.blocked.left)
{
this.x -= x;
console.log(this.sprite.name, 'touch h-right', this.x);
}
else
{
}
if (this.bounce.x === 0)
{
this.velocity.x = 0;
}
else
{
this.velocity.x = -this.velocity.x * this.bounce.x;
if (Math.abs(this.velocity.x) < this.minVelocity.x)
{
this.velocity.x = 0;
}
}
}
this.sprite.x += this.deltaX();
this.sprite.y += this.deltaY();
console.log(this.sprite.name, 'separate finished. Sprite.x', this.sprite.x, 'body x', this.x);
// reset delta ready for next collision
this.preX = this.x;
this.preY = this.y;
},
/**
* Internal method. This is called directly before the sprites are sent to the renderer.
*
@@ -567,27 +761,28 @@ Phaser.Physics.Arcade.Body.prototype = {
if (this.moves)
{
if (this.deltaX() < 0)
{
this.facing = Phaser.LEFT;
this.sprite.x += this.deltaX();
}
else if (this.deltaX() > 0)
{
this.facing = Phaser.RIGHT;
this.sprite.x += this.deltaX();
}
// if (this.deltaX() < 0)
// {
// this.facing = Phaser.LEFT;
// }
// else if (this.deltaX() > 0)
// {
// this.facing = Phaser.RIGHT;
// this.sprite.x += this.deltaX();
// }
if (this.deltaY() < 0)
{
this.facing = Phaser.UP;
this.sprite.y += this.deltaY();
}
else if (this.deltaY() > 0)
{
this.facing = Phaser.DOWN;
this.sprite.y += this.deltaY();
}
// if (this.deltaY() < 0)
// {
// this.facing = Phaser.UP;
// this.sprite.y += this.deltaY();
// }
// else if (this.deltaY() > 0)
// {
// this.facing = Phaser.DOWN;
// }
this.sprite.x += this.deltaX();
this.sprite.y += this.deltaY();
this.center.setTo(this.x + this.halfWidth, this.y + this.halfHeight);
@@ -599,41 +794,6 @@ Phaser.Physics.Arcade.Body.prototype = {
},
/**
* Internal method used to check the Body against the World Bounds.
*
* @method Phaser.Physics.Arcade#checkWorldBounds
* @protected
*/
checkWorldBounds: function () {
if (this.x < this.game.world.bounds.x)
{
this.overlapX = this.game.world.bounds.x - this.x;
this.blocked.left = true;
// console.log(this._debug, 'cwl', this.overlapX, this.x, this.game.world.bounds.x);
}
else if (this.right > this.game.world.bounds.right)
{
this.overlapX = this.right - this.game.world.bounds.right;
this.blocked.right = true;
// console.log(this._debug, 'cwr', this.overlapX, this.x, this.game.world.bounds.x);
}
if (this.y < this.game.world.bounds.y)
{
this.overlapY = this.game.world.bounds.y - this.y;
this.blocked.up = true;
// console.log(this._debug, 'cwu', this.overlapY, this.y, this.height, this.bottom, this.game.world.bounds.bottom);
}
else if (this.bottom > this.game.world.bounds.bottom)
{
this.overlapY = this.bottom - this.game.world.bounds.bottom;
this.blocked.down = true;
// console.log(this._debug, 'cwd', this.overlapY, this.y, this.height, this.bottom, this.game.world.bounds.bottom);
}
},
/**
* You can modify the size of the physics Body to be any dimension you need.
+16 -11
View File
@@ -20,32 +20,32 @@ Phaser.Time = function (game) {
this.game = game;
/**
* @property {number} physicsElapsed - The elapsed time calculated for the physics motion updates.
*/
this.physicsElapsed = 0;
/**
* @property {number} time - Game time counter.
* @property {number} time - Game time counter. If you need a value for in-game calculation please use Phaser.Time.now instead.
* @protected
*/
this.time = 0;
/**
* @property {number} pausedTime - Records how long the game has been paused for. Is reset each time the game pauses.
*/
this.pausedTime = 0;
/**
* @property {number} now - The time right now.
* @protected
*/
this.now = 0;
/**
* @property {number} elapsed - Elapsed time since the last frame (in ms).
* @protected
*/
this.elapsed = 0;
/**
* @property {number} pausedTime - Records how long the game has been paused for. Is reset each time the game pauses.
* @protected
*/
this.pausedTime = 0;
/**
* @property {number} fps - Frames per second.
* @protected
*/
this.fps = 0;
@@ -70,6 +70,11 @@ Phaser.Time = function (game) {
*/
this.msMax = 0;
/**
* @property {number} physicsElapsed - The elapsed time calculated for the physics motion updates.
*/
this.physicsElapsed = 0;
/**
* @property {number} frames - The number of frames record in the last second.
*/
+12
View File
@@ -75,6 +75,18 @@ Phaser.Utils = {
},
/**
* Returns true if the object is an Array, otherwise false.
* @method Phaser.Utils.isArray
* @param {object} obj - The object to inspect.
* @return {boolean} - true if the object is an array, otherwise false.
*/
isArray: function (obj) {
return toString.call(obj) === "[object Array]";
},
/**
* This is a slightly modified version of jQuery.isPlainObject. A plain object is an object whose internal class property is [object Object].
* @method Phaser.Utils.isPlainObject