P2.Body now uses the new Body.type value instead of Body.motionState, however as P2.Body already have a property called type we have left the motionState getter/setter in for now.

This commit is contained in:
photonstorm 2014-08-28 00:39:47 +01:00
parent 4935a4e4af
commit 98ccae56de
2 changed files with 56 additions and 26 deletions

View file

@ -73,11 +73,6 @@ Version 2.1.0 - "Cairhien" - -in development-
* TypeScript definition updates to help fix for the `noimplicitany` option (thanks @Waog #1088) * TypeScript definition updates to help fix for the `noimplicitany` option (thanks @Waog #1088)
* All of the Pixi geom classes have been removed from the build file as they aren't needed (the Phaser.Geom classes overwrite them), saving some space in the process. * All of the Pixi geom classes have been removed from the build file as they aren't needed (the Phaser.Geom classes overwrite them), saving some space in the process.
### p2.js changes
* DistanceConstraint signature changed to take the new localAnchors.
* RevoluteConstraint signature changed to include worldPivot
### New Features ### New Features
* Device will now detect for Kindle and PS Vita (thanks @lucbloom) * Device will now detect for Kindle and PS Vita (thanks @lucbloom)
@ -96,6 +91,41 @@ Version 2.1.0 - "Cairhien" - -in development-
* Group.swap() updates the Z index values properly (thanks @Blank101 #1090) * Group.swap() updates the Z index values properly (thanks @Blank101 #1090)
* Device now recognises ChromeOS as a desktop (thanks @alvinsight @hilts-vaughan #1091) * Device now recognises ChromeOS as a desktop (thanks @alvinsight @hilts-vaughan #1091)
### p2.js 0.6.0 Changes
* DistanceConstraint signature changed to take the new localAnchors.
* RevoluteConstraint signature changed to include worldPivot
* P2.Body now uses the new Body.type value instead of Body.motionState, however as P2.Body already have a property called `type` we have left the `motionState` getter/setter in for now.
#### Breaking changes
* Renamed property .motionState to .type in class Body.
* Changed constructor of RevoluteConstraint. Now the local pivots are passed as options instead of direct arguments. See the constraints demo.
* Removed World.prototype.toJSON and .fromJSON.
* Removed properties .enableBodySleeping and .enableIslandSleeping from World instances. The enum .sleepMode can be used instead. See the sleep demo.
* Converted Spring to a base class for the new LinearSpring and RotationalSpring classes. LinearSpring can be used as the old Spring.
* Utils.ARRAY_TYPE can now be overridden by injecting a global called P2_ARRAY_TYPE. Support for GLMAT_ARRAY_TYPE has been removed.
#### Other changes
* Added flag .enableFrictionReduction to Narrowphase.
* Added RevoluteConstraint.prototype.setLimits.
* Added PrismaticConstraint.prototype.setLimits.
* LockConstraint, DistanceConstraint, and GearConstraint can now be constructed from current body transforms.
* RevoluteConstraint can now be constructed from the current body transforms and a world point.
* Material id can now be passed via constructor.
* ContactMaterial instances now have a property .contactSkinSize.
* Added method Body.prototype.getAABB.
* Limits for DistanceConstraint. See the DistanceConstraint demo.
* Added Body.prototype.overlaps.
* Added class OverlapKeeper.
* If substepping is used in World.prototype.step, the substeps are aborted if slower than real time.
* Added Heightfield/Convex and Heightfield/Circle collision support.
* Added property .overlapKeeper to World.
* EventEmitter.prototype.has can now check if any listeners were added to a given topic.
* Added Utils.defaults.
The full Change Log is at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md The full Change Log is at https://github.com/photonstorm/phaser/blob/master/CHANGELOG.md
![div](http://phaser.io/images/div3.png) ![div](http://phaser.io/images/div3.png)

View file

@ -1299,7 +1299,7 @@ Phaser.Physics.P2.Body.prototype = {
Phaser.Physics.P2.Body.prototype.constructor = Phaser.Physics.P2.Body; Phaser.Physics.P2.Body.prototype.constructor = Phaser.Physics.P2.Body;
/** /**
* Dynamic body. * Dynamic body. Dynamic bodies body can move and respond to collisions and forces.
* @property DYNAMIC * @property DYNAMIC
* @type {Number} * @type {Number}
* @static * @static
@ -1307,7 +1307,7 @@ Phaser.Physics.P2.Body.prototype.constructor = Phaser.Physics.P2.Body;
Phaser.Physics.P2.Body.DYNAMIC = 1; Phaser.Physics.P2.Body.DYNAMIC = 1;
/** /**
* Static body. * Static body. Static bodies do not move, and they do not respond to forces or collision.
* @property STATIC * @property STATIC
* @type {Number} * @type {Number}
* @static * @static
@ -1315,7 +1315,7 @@ Phaser.Physics.P2.Body.DYNAMIC = 1;
Phaser.Physics.P2.Body.STATIC = 2; Phaser.Physics.P2.Body.STATIC = 2;
/** /**
* Kinematic body. * Kinematic body. Kinematic bodies only moves according to its .velocity, and does not respond to collisions or force.
* @property KINEMATIC * @property KINEMATIC
* @type {Number} * @type {Number}
* @static * @static
@ -1330,20 +1330,20 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "static", {
get: function () { get: function () {
return (this.data.motionState === Phaser.Physics.P2.Body.STATIC); return (this.data.type === Phaser.Physics.P2.Body.STATIC);
}, },
set: function (value) { set: function (value) {
if (value && this.data.motionState !== Phaser.Physics.P2.Body.STATIC) if (value && this.data.type !== Phaser.Physics.P2.Body.STATIC)
{ {
this.data.motionState = Phaser.Physics.P2.Body.STATIC; this.data.type = Phaser.Physics.P2.Body.STATIC;
this.mass = 0; this.mass = 0;
} }
else if (!value && this.data.motionState === Phaser.Physics.P2.Body.STATIC) else if (!value && this.data.type === Phaser.Physics.P2.Body.STATIC)
{ {
this.data.motionState = Phaser.Physics.P2.Body.DYNAMIC; this.data.type = Phaser.Physics.P2.Body.DYNAMIC;
if (this.mass === 0) if (this.mass === 0)
{ {
@ -1363,24 +1363,24 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "dynamic", {
get: function () { get: function () {
return (this.data.motionState === Phaser.Physics.P2.Body.DYNAMIC); return (this.data.type === Phaser.Physics.P2.Body.DYNAMIC);
}, },
set: function (value) { set: function (value) {
if (value && this.data.motionState !== Phaser.Physics.P2.Body.DYNAMIC) if (value && this.data.type !== Phaser.Physics.P2.Body.DYNAMIC)
{ {
this.data.motionState = Phaser.Physics.P2.Body.DYNAMIC; this.data.type = Phaser.Physics.P2.Body.DYNAMIC;
if (this.mass === 0) if (this.mass === 0)
{ {
this.mass = 1; this.mass = 1;
} }
} }
else if (!value && this.data.motionState === Phaser.Physics.P2.Body.DYNAMIC) else if (!value && this.data.type === Phaser.Physics.P2.Body.DYNAMIC)
{ {
this.data.motionState = Phaser.Physics.P2.Body.STATIC; this.data.type = Phaser.Physics.P2.Body.STATIC;
this.mass = 0; this.mass = 0;
} }
@ -1396,20 +1396,20 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "kinematic", {
get: function () { get: function () {
return (this.data.motionState === Phaser.Physics.P2.Body.KINEMATIC); return (this.data.type === Phaser.Physics.P2.Body.KINEMATIC);
}, },
set: function (value) { set: function (value) {
if (value && this.data.motionState !== Phaser.Physics.P2.Body.KINEMATIC) if (value && this.data.type !== Phaser.Physics.P2.Body.KINEMATIC)
{ {
this.data.motionState = Phaser.Physics.P2.Body.KINEMATIC; this.data.type = Phaser.Physics.P2.Body.KINEMATIC;
this.mass = 4; this.mass = 4;
} }
else if (!value && this.data.motionState === Phaser.Physics.P2.Body.KINEMATIC) else if (!value && this.data.type === Phaser.Physics.P2.Body.KINEMATIC)
{ {
this.data.motionState = Phaser.Physics.P2.Body.STATIC; this.data.type = Phaser.Physics.P2.Body.STATIC;
this.mass = 0; this.mass = 0;
} }
@ -1621,15 +1621,15 @@ Object.defineProperty(Phaser.Physics.P2.Body.prototype, "motionState", {
get: function () { get: function () {
return this.data.motionState; return this.data.type;
}, },
set: function (value) { set: function (value) {
if (value !== this.data.motionState) if (value !== this.data.type)
{ {
this.data.motionState = value; this.data.type = value;
} }
} }