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