Skip to content

Commit 6fbaa36

Browse files
committed
P2.PointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
P2.InversePointProxy.mx and my values are get and set in meters with no pixel conversion taking place. P2.PointProxy.x and y values are now returned in pixels (previously they were returned in meters). See PointProxy.mx/my for meter values. P2.InversePointProxy.x and y values are now returned in pixels (previously they were returned in meters). See PointProxy.mx/my for meter values.
1 parent 8bc4f90 commit 6fbaa36

3 files changed

Lines changed: 94 additions & 10 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ Version 2.1.0 - "Cairhien" - -in development-
9090
* Input.Gamepad.destroy now destroys all connected SinglePads and clears event listeners.
9191
* SinglePad.destroy now clears all associated GamepadButton objects and signals.
9292
* Device.node and Device.nodeWebKit are two new properties (thanks @videlais #1129)
93+
* P2.PointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
94+
* P2.InversePointProxy.mx and my values are get and set in meters with no pixel conversion taking place.
9395

9496
### Updates
9597

9698
* TypeScript definition updates to help fix for the `noimplicitany` option (thanks @Waog #1088)
97-
* TypeScript definitions fixes and updates (thanks @clark-stevenson and @rhmoller)
99+
* TypeScript definitions fixes and updates (thanks @clark-stevenson @englercj and @rhmoller)
98100
* 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.
99101
* Improved consistency of clone methods on geometry classes (thanks @beeglebug #1130)
100102
* Removed Cache.isSpriteSheet method as no longer required (see #1059)
@@ -108,6 +110,8 @@ Version 2.1.0 - "Cairhien" - -in development-
108110
* P2.World.defaultFriction and defaultRestitution have been removed due to deprecation.
109111
* Canvas.create noCocoon parameter has been removed due to deprecation.
110112
* Color.getColorInfo, RGBtoHexstring, RGBtoWebstring and colorToHexstring has been removed due to deprecation.
113+
* P2.PointProxy.x and y values are now returned in pixels (previously they were returned in meters). See PointProxy.mx/my for meter values.
114+
* P2.InversePointProxy.x and y values are now returned in pixels (previously they were returned in meters). See PointProxy.mx/my for meter values.
111115

112116
### Bug Fixes
113117

src/physics/p2/InversePointProxy.js

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,70 @@ Phaser.Physics.P2.InversePointProxy.prototype.constructor = Phaser.Physics.P2.In
2424

2525
/**
2626
* @name Phaser.Physics.P2.InversePointProxy#x
27-
* @property {number} x - The x property of this InversePointProxy.
27+
* @property {number} x - The x property of this InversePointProxy get and set in pixels.
2828
*/
2929
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "x", {
3030

3131
get: function () {
3232

33-
return this.destination[0];
33+
return this.world.mpxi(this.destination[0]);
3434

3535
},
3636

3737
set: function (value) {
3838

39-
this.destination[0] = this.world.pxm(-value);
39+
this.destination[0] = this.world.pxmi(value);
4040

4141
}
4242

4343
});
4444

4545
/**
4646
* @name Phaser.Physics.P2.InversePointProxy#y
47-
* @property {number} y - The y property of this InversePointProxy.
47+
* @property {number} y - The y property of this InversePointProxy get and set in pixels.
4848
*/
4949
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
5050

51+
get: function () {
52+
53+
return this.world.mpxi(this.destination[1]);
54+
55+
},
56+
57+
set: function (value) {
58+
59+
this.destination[1] = this.world.pxmi(value);
60+
61+
}
62+
63+
});
64+
65+
/**
66+
* @name Phaser.Physics.P2.InversePointProxy#mx
67+
* @property {number} mx - The x property of this InversePointProxy get and set in meters.
68+
*/
69+
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "mx", {
70+
71+
get: function () {
72+
73+
return this.destination[0];
74+
75+
},
76+
77+
set: function (value) {
78+
79+
this.destination[0] = -value;
80+
81+
}
82+
83+
});
84+
85+
/**
86+
* @name Phaser.Physics.P2.InversePointProxy#my
87+
* @property {number} my - The y property of this InversePointProxy get and set in meters.
88+
*/
89+
Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "my", {
90+
5191
get: function () {
5292

5393
return this.destination[1];
@@ -56,7 +96,7 @@ Object.defineProperty(Phaser.Physics.P2.InversePointProxy.prototype, "y", {
5696

5797
set: function (value) {
5898

59-
this.destination[1] = this.world.pxm(-value);
99+
this.destination[1] = -value;
60100

61101
}
62102

src/physics/p2/PointProxy.js

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ Phaser.Physics.P2.PointProxy.prototype.constructor = Phaser.Physics.P2.PointProx
2424

2525
/**
2626
* @name Phaser.Physics.P2.PointProxy#x
27-
* @property {number} x - The x property of this PointProxy.
27+
* @property {number} x - The x property of this PointProxy get and set in pixels.
2828
*/
2929
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
3030

3131
get: function () {
3232

33-
return this.destination[0];
33+
return this.world.mpx(this.destination[0]);
3434

3535
},
3636

@@ -44,13 +44,13 @@ Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "x", {
4444

4545
/**
4646
* @name Phaser.Physics.P2.PointProxy#y
47-
* @property {number} y - The y property of this PointProxy.
47+
* @property {number} y - The y property of this PointProxy get and set in pixels.
4848
*/
4949
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
5050

5151
get: function () {
5252

53-
return this.destination[1];
53+
return this.world.mpx(this.destination[1]);
5454

5555
},
5656

@@ -61,3 +61,43 @@ Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "y", {
6161
}
6262

6363
});
64+
65+
/**
66+
* @name Phaser.Physics.P2.PointProxy#mx
67+
* @property {number} mx - The x property of this PointProxy get and set in meters.
68+
*/
69+
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "mx", {
70+
71+
get: function () {
72+
73+
return this.destination[0];
74+
75+
},
76+
77+
set: function (value) {
78+
79+
this.destination[0] = value;
80+
81+
}
82+
83+
});
84+
85+
/**
86+
* @name Phaser.Physics.P2.PointProxy#my
87+
* @property {number} my - The x property of this PointProxy get and set in meters.
88+
*/
89+
Object.defineProperty(Phaser.Physics.P2.PointProxy.prototype, "my", {
90+
91+
get: function () {
92+
93+
return this.destination[1];
94+
95+
},
96+
97+
set: function (value) {
98+
99+
this.destination[1] = value;
100+
101+
}
102+
103+
});

0 commit comments

Comments
 (0)