2014-02-18 15:16:26 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2015-02-25 03:36:23 +00:00
|
|
|
* @copyright 2015 Photon Storm Ltd.
|
2014-02-18 15:16:26 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set.
|
|
|
|
*
|
2014-03-05 02:36:08 +00:00
|
|
|
* @class Phaser.Physics.P2.InversePointProxy
|
2014-02-18 15:16:26 +00:00
|
|
|
* @constructor
|
2014-03-12 00:07:27 +00:00
|
|
|
* @param {Phaser.Physics.P2} world - A reference to the P2 World.
|
2014-02-18 15:16:26 +00:00
|
|
|
* @param {any} destination - The object to bind to.
|
|
|
|
*/
|
2014-03-12 00:07:27 +00:00
|
|
|
Phaser.Physics.P2.InversePointProxy = function (world, destination) {
|
2014-02-18 15:16:26 +00:00
|
|
|
|
2014-03-12 00:07:27 +00:00
|
|
|
this.world = world;
|
2014-02-18 15:16:26 +00:00
|
|
|
this.destination = destination;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-03-05 02:36:08 +00:00
|
|
|
Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.InversePointProxy;
|
2014-02-18 15:16:26 +00:00
|
|
|
|
|
|
|
/**
|
2014-03-05 02:36:08 +00:00
|
|
|
* @name Phaser.Physics.P2.InversePointProxy#x
|
2014-08-28 15:29:07 +00:00
|
|
|
* @property {number} x - The x property of this InversePointProxy get and set in pixels.
|
2014-02-18 15:16:26 +00:00
|
|
|
*/
|
2014-03-05 02:36:08 +00:00
|
|
|
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2014-02-18 15:16:26 +00:00
|
|
|
get: function () {
|
|
|
|
|
2014-08-28 15:29:07 +00:00
|
|
|
return this.world.mpxi(this.destination[0]);
|
2014-02-18 15:16:26 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
2014-08-28 15:29:07 +00:00
|
|
|
this.destination[0] = this.world.pxmi(value);
|
2014-02-18 15:16:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2014-03-05 02:36:08 +00:00
|
|
|
* @name Phaser.Physics.P2.InversePointProxy#y
|
2014-08-28 15:29:07 +00:00
|
|
|
* @property {number} y - The y property of this InversePointProxy get and set in pixels.
|
2014-02-18 15:16:26 +00:00
|
|
|
*/
|
2014-03-05 02:36:08 +00:00
|
|
|
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
|
2014-03-23 07:59:28 +00:00
|
|
|
|
2014-08-28 15:29:07 +00:00
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.world.mpxi(this.destination[1]);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
|
|
|
this.destination[1] = this.world.pxmi(value);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Phaser.Physics.P2.InversePointProxy#mx
|
|
|
|
* @property {number} mx - The x property of this InversePointProxy get and set in meters.
|
|
|
|
*/
|
|
|
|
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "mx", {
|
|
|
|
|
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.destination[0];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
|
|
|
this.destination[0] = -value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Phaser.Physics.P2.InversePointProxy#my
|
|
|
|
* @property {number} my - The y property of this InversePointProxy get and set in meters.
|
|
|
|
*/
|
|
|
|
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "my", {
|
|
|
|
|
2014-02-18 15:16:26 +00:00
|
|
|
get: function () {
|
|
|
|
|
|
|
|
return this.destination[1];
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
set: function (value) {
|
|
|
|
|
2014-08-28 15:29:07 +00:00
|
|
|
this.destination[1] = -value;
|
2014-02-18 15:16:26 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|