Skip to content

Commit 15be3f8

Browse files
committed
Added ContactMaterial support.
1 parent 3d0b5bd commit 15be3f8

4 files changed

Lines changed: 87 additions & 0 deletions

File tree

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ module.exports = function (grunt) {
139139
'src/physics/Body.js',
140140
'src/physics/Spring.js',
141141
'src/physics/Material.js',
142+
'src/physics/ContactMaterial.js',
142143

143144
'src/particles/Particles.js',
144145
'src/particles/arcade/ArcadeParticles.js',

build/config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
<script src="$path/src/physics/Body.js"></script>
186186
<script src="$path/src/physics/Spring.js"></script>
187187
<script src="$path/src/physics/Material.js"></script>
188+
<script src="$path/src/physics/ContactMaterial.js"></script>
188189
189190
<script src="$path/src/particles/Particles.js"></script>
190191
<script src="$path/src/particles/arcade/ArcadeParticles.js"></script>

src/physics/ContactMaterial.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2014 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* Defines a physics material
9+
*
10+
* @class Phaser.Physics.ContactMaterial
11+
* @classdesc Physics ContactMaterial Constructor
12+
* @constructor
13+
* @param {Phaser.Physics.Material} materialA
14+
* @param {Phaser.Physics.Material} materialB
15+
* @param {object} [options]
16+
*/
17+
Phaser.Physics.ContactMaterial = function (materialA, materialB, options) {
18+
19+
/**
20+
* @property {number} id - The contact material identifier.
21+
*/
22+
23+
/**
24+
* @property {Phaser.Physics.Material} materialA - First material participating in the contact material.
25+
*/
26+
27+
/**
28+
* @property {Phaser.Physics.Material} materialB - First second participating in the contact material.
29+
*/
30+
31+
/**
32+
* @property {number} [friction=0.3] - Friction to use in the contact of these two materials.
33+
*/
34+
35+
/**
36+
* @property {number} [restitution=0.0] - Restitution to use in the contact of these two materials.
37+
*/
38+
39+
/**
40+
* @property {number} [stiffness=1e7] - Stiffness of the resulting ContactEquation that this ContactMaterial generate.
41+
*/
42+
43+
/**
44+
* @property {number} [relaxation=3] - Relaxation of the resulting ContactEquation that this ContactMaterial generate.
45+
*/
46+
47+
/**
48+
* @property {number} [frictionStiffness=1e7] - Stiffness of the resulting FrictionEquation that this ContactMaterial generate.
49+
*/
50+
51+
/**
52+
* @property {number} [frictionRelaxation=3] - Relaxation of the resulting FrictionEquation that this ContactMaterial generate.
53+
*/
54+
55+
/**
56+
* @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.
57+
*/
58+
59+
p2.ContactMaterial.call(this, materialA, materialB, options);
60+
61+
}
62+
63+
Phaser.Physics.ContactMaterial.prototype = Object.create(p2.ContactMaterial.prototype);
64+
Phaser.Physics.ContactMaterial.prototype.constructor = Phaser.Physics.ContactMaterial;

src/physics/Material.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @author Richard Davey <rich@photonstorm.com>
3+
* @copyright 2014 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* \o/ ~ "Because I'm a Material girl"
9+
*
10+
* @class Phaser.Physics.Material
11+
* @classdesc Physics Material Constructor
12+
* @constructor
13+
*/
14+
Phaser.Physics.Material = function () {
15+
16+
p2.Material.call(this);
17+
18+
}
19+
20+
Phaser.Physics.Material.prototype = Object.create(p2.Material.prototype);
21+
Phaser.Physics.Material.prototype.constructor = Phaser.Physics.Material;

0 commit comments

Comments
 (0)