mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 04:33:31 +00:00
Added jsdocs.
This commit is contained in:
parent
a71998d682
commit
5db058021f
9 changed files with 487 additions and 44 deletions
|
@ -1,5 +1,3 @@
|
||||||
// Phaser.Physics.Impact.Body
|
|
||||||
|
|
||||||
var Class = require('../../utils/Class');
|
var Class = require('../../utils/Class');
|
||||||
var COLLIDES = require('./COLLIDES');
|
var COLLIDES = require('./COLLIDES');
|
||||||
var GetVelocity = require('./GetVelocity');
|
var GetVelocity = require('./GetVelocity');
|
||||||
|
@ -7,10 +5,21 @@ var TYPE = require('./TYPE');
|
||||||
var UpdateMotion = require('./UpdateMotion');
|
var UpdateMotion = require('./UpdateMotion');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Impact.js compatible physics body.
|
* @classdesc
|
||||||
* This re-creates the properties you'd get on an Entity and the math needed to update them.
|
* An Impact.js compatible physics body.
|
||||||
*/
|
* This re-creates the properties you'd get on an Entity and the math needed to update them.
|
||||||
|
*
|
||||||
|
* @class Body
|
||||||
|
* @memberOf Phaser.Physics.Impact
|
||||||
|
* @constructor
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Physics.Impact.World} world - [description]
|
||||||
|
* @param {number} x - [description]
|
||||||
|
* @param {number} y - [description]
|
||||||
|
* @param {number} [sx=16] - [description]
|
||||||
|
* @param {number} [sy=16] - [description]
|
||||||
|
*/
|
||||||
var Body = new Class({
|
var Body = new Class({
|
||||||
|
|
||||||
initialize:
|
initialize:
|
||||||
|
@ -20,51 +29,284 @@ var Body = new Class({
|
||||||
if (sx === undefined) { sx = 16; }
|
if (sx === undefined) { sx = 16; }
|
||||||
if (sy === undefined) { sy = sx; }
|
if (sy === undefined) { sy = sx; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#world
|
||||||
|
* @type {Phaser.Physics.Impact.World}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#gameObject
|
||||||
|
* @type {Phaser.GameObjects.GameObject}
|
||||||
|
* @default null
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.gameObject = null;
|
this.gameObject = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#enabled
|
||||||
|
* @type {boolean}
|
||||||
|
* @default true
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#parent
|
||||||
|
* @type {null}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.parent;
|
this.parent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#id
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.id = world.getNextID();
|
this.id = world.getNextID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#name
|
||||||
|
* @type {string}
|
||||||
|
* @default ''
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.name = '';
|
this.name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#size
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.size = { x: sx, y: sy };
|
this.size = { x: sx, y: sy };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#offset
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.offset = { x: 0, y: 0 };
|
this.offset = { x: 0, y: 0 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#pos
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.pos = { x: x, y: y };
|
this.pos = { x: x, y: y };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#last
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.last = { x: x, y: y };
|
this.last = { x: x, y: y };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#vel
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.vel = { x: 0, y: 0 };
|
this.vel = { x: 0, y: 0 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#accel
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.accel = { x: 0, y: 0 };
|
this.accel = { x: 0, y: 0 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#friction
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.friction = { x: 0, y: 0 };
|
this.friction = { x: 0, y: 0 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#maxVel
|
||||||
|
* @type {{x: number, y: number}}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY };
|
this.maxVel = { x: world.defaults.maxVelocityX, y: world.defaults.maxVelocityY };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#standing
|
||||||
|
* @type {boolean}
|
||||||
|
* @default false
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.standing = false;
|
this.standing = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#gravityFactor
|
||||||
|
* @type {number}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.gravityFactor = world.defaults.gravityFactor;
|
this.gravityFactor = world.defaults.gravityFactor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#bounciness
|
||||||
|
* @type {number}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.bounciness = world.defaults.bounciness;
|
this.bounciness = world.defaults.bounciness;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#minBounceVelocity
|
||||||
|
* @type {number}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.minBounceVelocity = world.defaults.minBounceVelocity;
|
this.minBounceVelocity = world.defaults.minBounceVelocity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#accelGround
|
||||||
|
* @type {number}
|
||||||
|
* @default 0
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.accelGround = 0;
|
this.accelGround = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#accelAir
|
||||||
|
* @type {number}
|
||||||
|
* @default 0
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.accelAir = 0;
|
this.accelAir = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#jumpSpeed
|
||||||
|
* @type {number}
|
||||||
|
* @default 0
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.jumpSpeed = 0;
|
this.jumpSpeed = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#type
|
||||||
|
* @type {Phaser.Physics.Impact.TYPE}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.type = TYPE.NONE;
|
this.type = TYPE.NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#checkAgainst
|
||||||
|
* @type {Phaser.Physics.Impact.TYPE}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.checkAgainst = TYPE.NONE;
|
this.checkAgainst = TYPE.NONE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#collides
|
||||||
|
* @type {Phaser.Physics.Impact.COLLIDES}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.collides = COLLIDES.NEVER;
|
this.collides = COLLIDES.NEVER;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#debugShowBody
|
||||||
|
* @type {boolean}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.debugShowBody = world.defaults.debugShowBody;
|
this.debugShowBody = world.defaults.debugShowBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#debugShowVelocity
|
||||||
|
* @type {boolean}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.debugShowVelocity = world.defaults.debugShowVelocity;
|
this.debugShowVelocity = world.defaults.debugShowVelocity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#debugBodyColor
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.debugBodyColor = world.defaults.bodyDebugColor;
|
this.debugBodyColor = world.defaults.bodyDebugColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#updateCallback
|
||||||
|
* @type {function}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.updateCallback;
|
this.updateCallback;
|
||||||
|
|
||||||
// min 44 deg, max 136 deg
|
/**
|
||||||
|
* min 44 deg, max 136 deg
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.Body#slopeStanding
|
||||||
|
* @type {{ min: number, max: number }}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 };
|
this.slopeStanding = { min: 0.767944870877505, max: 2.3736477827122884 };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#reset
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {number} x - [description]
|
||||||
|
* @param {number} y - [description]
|
||||||
|
*/
|
||||||
reset: function (x, y)
|
reset: function (x, y)
|
||||||
{
|
{
|
||||||
this.pos = { x: x, y: y };
|
this.pos = { x: x, y: y };
|
||||||
|
@ -89,6 +331,14 @@ var Body = new Class({
|
||||||
this.collides = COLLIDES.NEVER;
|
this.collides = COLLIDES.NEVER;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#update
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {number} delta - [description]
|
||||||
|
*/
|
||||||
update: function (delta)
|
update: function (delta)
|
||||||
{
|
{
|
||||||
var pos = this.pos;
|
var pos = this.pos;
|
||||||
|
@ -125,6 +375,14 @@ var Body = new Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#drawDebug
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.GameObjects.Graphics} graphic - [description]
|
||||||
|
*/
|
||||||
drawDebug: function (graphic)
|
drawDebug: function (graphic)
|
||||||
{
|
{
|
||||||
var pos = this.pos;
|
var pos = this.pos;
|
||||||
|
@ -145,16 +403,42 @@ var Body = new Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#willDrawDebug
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @return {boolean} [description]
|
||||||
|
*/
|
||||||
willDrawDebug: function ()
|
willDrawDebug: function ()
|
||||||
{
|
{
|
||||||
return (this.debugShowBody || this.debugShowVelocity);
|
return (this.debugShowBody || this.debugShowVelocity);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#skipHash
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @return {boolean} [description]
|
||||||
|
*/
|
||||||
skipHash: function ()
|
skipHash: function ()
|
||||||
{
|
{
|
||||||
return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0));
|
return (!this.enabled || (this.type === 0 && this.checkAgainst === 0 && this.collides === 0));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#touches
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Physics.Impact.Body} other - [description]
|
||||||
|
*
|
||||||
|
* @return {boolean} [description]
|
||||||
|
*/
|
||||||
touches: function (other)
|
touches: function (other)
|
||||||
{
|
{
|
||||||
return !(
|
return !(
|
||||||
|
@ -165,6 +449,19 @@ var Body = new Class({
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#resetSize
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {number} x - [description]
|
||||||
|
* @param {number} y - [description]
|
||||||
|
* @param {number} width - [description]
|
||||||
|
* @param {number} height - [description]
|
||||||
|
*
|
||||||
|
* @return {Phaser.Physics.Impact.Body} This Body object.
|
||||||
|
*/
|
||||||
resetSize: function (x, y, width, height)
|
resetSize: function (x, y, width, height)
|
||||||
{
|
{
|
||||||
this.pos.x = x;
|
this.pos.x = x;
|
||||||
|
@ -175,6 +472,14 @@ var Body = new Class({
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#toJSON
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @return {object} [description]
|
||||||
|
*/
|
||||||
toJSON: function ()
|
toJSON: function ()
|
||||||
{
|
{
|
||||||
var output = {
|
var output = {
|
||||||
|
@ -196,17 +501,40 @@ var Body = new Class({
|
||||||
return output;
|
return output;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#fromJSON
|
||||||
|
* @todo
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {object} config - [description]
|
||||||
|
*/
|
||||||
fromJSON: function (config)
|
fromJSON: function (config)
|
||||||
{
|
{
|
||||||
// TODO
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Can be overridden by user code
|
/**
|
||||||
|
* Can be overridden by user code
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#check
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {[type]} other - [description]
|
||||||
|
*/
|
||||||
check: function (other)
|
check: function (other)
|
||||||
{
|
{
|
||||||
},
|
},
|
||||||
|
|
||||||
// Can be overridden by user code
|
/**
|
||||||
|
* Can be overridden by user code
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#collideWith
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Physics.Impact.Body} other - [description]
|
||||||
|
* @param {[type]} axis - [description]
|
||||||
|
*/
|
||||||
collideWith: function (other, axis)
|
collideWith: function (other, axis)
|
||||||
{
|
{
|
||||||
if (this.parent && this.parent._collideCallback)
|
if (this.parent && this.parent._collideCallback)
|
||||||
|
@ -215,12 +543,27 @@ var Body = new Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Can be overridden by user code but must return a boolean
|
/**
|
||||||
|
* Can be overridden by user code but must return a boolean.
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#handleMovementTrace
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {[type]} res - [description]
|
||||||
|
*
|
||||||
|
* @return {boolean} [description]
|
||||||
|
*/
|
||||||
handleMovementTrace: function (res)
|
handleMovementTrace: function (res)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @method Phaser.Physics.Impact.Body#destroy
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
destroy: function ()
|
destroy: function ()
|
||||||
{
|
{
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
|
|
|
@ -1,17 +1,60 @@
|
||||||
// Collision Types - Determine if and how entities collide with each other
|
/**
|
||||||
|
* Collision Types - Determine if and how entities collide with each other.
|
||||||
// In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
|
*
|
||||||
// while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
|
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
|
||||||
// collisions, both entities are moved. LITE or PASSIVE entities don't collide
|
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
|
||||||
// with other LITE or PASSIVE entities at all. The behaiviour for FIXED vs.
|
* collisions, both entities are moved. LITE or PASSIVE entities don't collide
|
||||||
// FIXED collisions is undefined.
|
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
|
||||||
|
* FIXED collisions is undefined.
|
||||||
|
*
|
||||||
|
* @namespace Phaser.Physics.Impact.COLLIDES
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Never collides.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.COLLIDES.NEVER
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
NEVER: 0,
|
NEVER: 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lite collision.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.COLLIDES.LITE
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
LITE: 1,
|
LITE: 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passive collision.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.COLLIDES.PASSIVE
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
PASSIVE: 2,
|
PASSIVE: 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Active collision.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.COLLIDES.ACTIVE
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
ACTIVE: 4,
|
ACTIVE: 4,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixed collision.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.COLLIDES.FIXED
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
FIXED: 8
|
FIXED: 8
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @function Phaser.Physics.Impact.SeperateX
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Physics.Impact.World} world - [description]
|
||||||
|
* @param {Phaser.Physics.Impact.Body} left - [description]
|
||||||
|
* @param {Phaser.Physics.Impact.Body} right - [description]
|
||||||
|
* @param {Phaser.Physics.Impact.Body} [weak] - [description]
|
||||||
|
*/
|
||||||
var SeperateX = function (world, left, right, weak)
|
var SeperateX = function (world, left, right, weak)
|
||||||
{
|
{
|
||||||
var nudge = left.pos.x + left.size.x - right.pos.x;
|
var nudge = left.pos.x + left.size.x - right.pos.x;
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
|
/**
|
||||||
|
* [description]
|
||||||
|
*
|
||||||
|
* @function Phaser.Physics.Impact.SeperateY
|
||||||
|
* @since 3.0.0
|
||||||
|
*
|
||||||
|
* @param {Phaser.Physics.Impact.World} world - [description]
|
||||||
|
* @param {Phaser.Physics.Impact.Body} top - [description]
|
||||||
|
* @param {Phaser.Physics.Impact.Body} bottom - [description]
|
||||||
|
* @param {Phaser.Physics.Impact.Body} [weak] - [description]
|
||||||
|
*/
|
||||||
var SeperateY = function (world, top, bottom, weak)
|
var SeperateY = function (world, top, bottom, weak)
|
||||||
{
|
{
|
||||||
var nudge = (top.pos.y + top.size.y - bottom.pos.y);
|
var nudge = (top.pos.y + top.size.y - bottom.pos.y);
|
||||||
|
|
|
@ -1,16 +1,51 @@
|
||||||
// Collision Types - Determine if and how entities collide with each other
|
/**
|
||||||
|
* Collision Types - Determine if and how entities collide with each other.
|
||||||
// In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
|
*
|
||||||
// while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
|
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
|
||||||
// collisions, both entities are moved. LITE or PASSIVE entities don't collide
|
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
|
||||||
// with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
|
* collisions, both entities are moved. LITE or PASSIVE entities don't collide
|
||||||
// FIXED collisions is undefined.
|
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
|
||||||
|
* FIXED collisions is undefined.
|
||||||
|
*
|
||||||
|
* @namespace Phaser.Physics.Impact.TYPES
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collides with nothing.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.TYPES.NONE
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
NONE: 0,
|
NONE: 0,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type A. Collides with Type B.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.TYPES.A
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
A: 1,
|
A: 1,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type B. Collides with Type A.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.TYPES.B
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
B: 2,
|
B: 2,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collides with both types A and B.
|
||||||
|
*
|
||||||
|
* @name Phaser.Physics.Impact.TYPES.BOTH
|
||||||
|
* @type {integer}
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
BOTH: 3
|
BOTH: 3
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
// Phaser.Physics.Impact
|
/**
|
||||||
|
* An Impact.js compatible physics world, body and solver, for those who are used
|
||||||
// An Impact.js compatible physics world, body and solver, for those who are used
|
* to the Impact way of defining and controlling physics bodies. Also works with
|
||||||
// to the Impact way of defining and controlling physics bodies. Also works with
|
* the new Loader support for Weltmeister map data.
|
||||||
// the new Loader support for Weltmeister map data.
|
*
|
||||||
//
|
* World updated to run off the Phaser main loop.
|
||||||
// World updated to run off the Phaser main loop.
|
* Body extended to support additional setter functions.
|
||||||
// Body extended to support additional setter functions.
|
*
|
||||||
//
|
* To create the map data you'll need Weltmeister, which comes with Impact
|
||||||
// To create the map data you'll need Weltmeister, which comes with Impact
|
* and can be purchased from http://impactjs.com
|
||||||
// and can be purchased from http://impactjs.com
|
*
|
||||||
//
|
* My thanks to Dominic Szablewski for his permission to support Impact in Phaser.
|
||||||
// My thanks to Dominic Szablewski for his permission to support Impact in Phaser.
|
*
|
||||||
|
* @namespace Phaser.Physics.Impact
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
Body: require('./Body'),
|
Body: require('./Body'),
|
||||||
Body: require('./ImpactBody'),
|
|
||||||
COLLIDES: require('./COLLIDES'),
|
COLLIDES: require('./COLLIDES'),
|
||||||
CollisionMap: require('./CollisionMap'),
|
CollisionMap: require('./CollisionMap'),
|
||||||
Factory: require('./Factory'),
|
Factory: require('./Factory'),
|
||||||
Image: require('./ImpactImage'),
|
Image: require('./ImpactImage'),
|
||||||
|
ImpactBody: require('./ImpactBody'),
|
||||||
ImpactPhysics: require('./ImpactPhysics'),
|
ImpactPhysics: require('./ImpactPhysics'),
|
||||||
Sprite: require('./ImpactSprite'),
|
Sprite: require('./ImpactSprite'),
|
||||||
TYPE: require('./TYPE'),
|
TYPE: require('./TYPE'),
|
||||||
|
|
|
@ -6,7 +6,6 @@ module.exports = {
|
||||||
|
|
||||||
Arcade: require('./arcade'),
|
Arcade: require('./arcade'),
|
||||||
Impact: require('./impact'),
|
Impact: require('./impact'),
|
||||||
Matter: require('./matter-js'),
|
Matter: require('./matter-js')
|
||||||
PolyDecomp: require('./poly-decomp')
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@ module.exports = {
|
||||||
Image: require('./MatterImage'),
|
Image: require('./MatterImage'),
|
||||||
Matter: require('./CustomMain'),
|
Matter: require('./CustomMain'),
|
||||||
MatterPhysics: require('./MatterPhysics'),
|
MatterPhysics: require('./MatterPhysics'),
|
||||||
|
PolyDecomp: require('./poly-decomp'),
|
||||||
Sprite: require('./MatterSprite'),
|
Sprite: require('./MatterSprite'),
|
||||||
TileBody: require('./MatterTileBody'),
|
TileBody: require('./MatterTileBody'),
|
||||||
World: require('./World')
|
World: require('./World')
|
||||||
|
|
Loading…
Reference in a new issue