mirror of
https://github.com/wassname/phaser.git
synced 2026-07-10 00:30:50 +08:00
Updated World vastly. No longer extends p2.World due to a few vars we can't alias cleanly, adds in lots of new helper methods.
Ready for Materials and Constraints. InversePointProxy is for aliasing a p2 typed array when the values need reversing before applying (gravity for example).
This commit is contained in:
@@ -135,8 +135,10 @@ module.exports = function (grunt) {
|
||||
|
||||
'src/physics/World.js',
|
||||
'src/physics/PointProxy.js',
|
||||
'src/physics/InversePointProxy.js',
|
||||
'src/physics/Body.js',
|
||||
'src/physics/Spring.js',
|
||||
'src/physics/Material.js',
|
||||
|
||||
'src/particles/Particles.js',
|
||||
'src/particles/arcade/ArcadeParticles.js',
|
||||
|
||||
@@ -181,8 +181,10 @@
|
||||
|
||||
<script src="$path/src/physics/World.js"></script>
|
||||
<script src="$path/src/physics/PointProxy.js"></script>
|
||||
<script src="$path/src/physics/InversePointProxy.js"></script>
|
||||
<script src="$path/src/physics/Body.js"></script>
|
||||
<script src="$path/src/physics/Spring.js"></script>
|
||||
<script src="$path/src/physics/Material.js"></script>
|
||||
|
||||
<script src="$path/src/particles/Particles.js"></script>
|
||||
<script src="$path/src/particles/arcade/ArcadeParticles.js"></script>
|
||||
|
||||
+2
-2
@@ -70,7 +70,7 @@ Phaser.Physics.Body = function (game, sprite, x, y, mass) {
|
||||
if (sprite)
|
||||
{
|
||||
this.setRectangleFromSprite(sprite);
|
||||
this.game.physics.addBody(this.data);
|
||||
this.game.physics.addBody(this);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -399,7 +399,7 @@ Phaser.Physics.Body.prototype = {
|
||||
|
||||
if (this.data.world !== this.game.physics)
|
||||
{
|
||||
this.game.physics.addBody(this.data);
|
||||
this.game.physics.addBody(this);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @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 InversePointProxy is an internal class that allows for direct getter/setter style property access to Arrays and TypedArrays but inverses the values on set.
|
||||
*
|
||||
* @class Phaser.Physics.InversePointProxy
|
||||
* @classdesc InversePointProxy
|
||||
* @constructor
|
||||
* @param {any} destination - The object to bind to.
|
||||
*/
|
||||
Phaser.Physics.InversePointProxy = function (destination) {
|
||||
|
||||
this.destination = destination;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Physics.InversePointProxy.prototype.constructor = Phaser.Physics.InversePointProxy;
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.InversePointProxy#x
|
||||
* @property {number} x - The x property of this InversePointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "x", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.destination[0];
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.destination[0] *= -value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* @name Phaser.Physics.InversePointProxy#y
|
||||
* @property {number} y - The y property of this InversePointProxy.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Physics.InversePointProxy.prototype, "y", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return this.destination[1];
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this.destination[1] *= -value;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
+723
-231
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user