mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Added ContactMaterial support.
This commit is contained in:
@@ -139,6 +139,7 @@ module.exports = function (grunt) {
|
||||
'src/physics/Body.js',
|
||||
'src/physics/Spring.js',
|
||||
'src/physics/Material.js',
|
||||
'src/physics/ContactMaterial.js',
|
||||
|
||||
'src/particles/Particles.js',
|
||||
'src/particles/arcade/ArcadeParticles.js',
|
||||
|
||||
@@ -185,6 +185,7 @@
|
||||
<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/physics/ContactMaterial.js"></script>
|
||||
|
||||
<script src="$path/src/particles/Particles.js"></script>
|
||||
<script src="$path/src/particles/arcade/ArcadeParticles.js"></script>
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Defines a physics material
|
||||
*
|
||||
* @class Phaser.Physics.ContactMaterial
|
||||
* @classdesc Physics ContactMaterial Constructor
|
||||
* @constructor
|
||||
* @param {Phaser.Physics.Material} materialA
|
||||
* @param {Phaser.Physics.Material} materialB
|
||||
* @param {object} [options]
|
||||
*/
|
||||
Phaser.Physics.ContactMaterial = function (materialA, materialB, options) {
|
||||
|
||||
/**
|
||||
* @property {number} id - The contact material identifier.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.Material} materialA - First material participating in the contact material.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {Phaser.Physics.Material} materialB - First second participating in the contact material.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [friction=0.3] - Friction to use in the contact of these two materials.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [restitution=0.0] - Restitution to use in the contact of these two materials.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [stiffness=1e7] - Stiffness of the resulting ContactEquation that this ContactMaterial generate.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [relaxation=3] - Relaxation of the resulting ContactEquation that this ContactMaterial generate.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [frictionStiffness=1e7] - Stiffness of the resulting FrictionEquation that this ContactMaterial generate.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [frictionRelaxation=3] - Relaxation of the resulting FrictionEquation that this ContactMaterial generate.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number} [surfaceVelocity=0] - Will add surface velocity to this material. If bodyA rests on top if bodyB, and the surface velocity is positive, bodyA will slide to the right.
|
||||
*/
|
||||
|
||||
p2.ContactMaterial.call(this, materialA, materialB, options);
|
||||
|
||||
}
|
||||
|
||||
Phaser.Physics.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype);
|
||||
Phaser.Physics.ContactMaterial.prototype.constructor = Phaser.Physics.ContactMaterial;
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2014 Photon Storm Ltd.
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
*/
|
||||
|
||||
/**
|
||||
* \o/ ~ "Because I'm a Material girl"
|
||||
*
|
||||
* @class Phaser.Physics.Material
|
||||
* @classdesc Physics Material Constructor
|
||||
* @constructor
|
||||
*/
|
||||
Phaser.Physics.Material = function () {
|
||||
|
||||
p2.Material.call(this);
|
||||
|
||||
}
|
||||
|
||||
Phaser.Physics.Material.prototype = Object.create(p2.Material.prototype);
|
||||
Phaser.Physics.Material.prototype.constructor = Phaser.Physics.Material;
|
||||
|
||||
Reference in New Issue
Block a user