Skip to content

Commit a3f298f

Browse files
committed
change all examples to use Composite.add instead of the alias World.add
1 parent 9ad980b commit a3f298f

43 files changed

Lines changed: 159 additions & 169 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/airFriction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Example.airFriction = function() {
66
Runner = Matter.Runner,
77
MouseConstraint = Matter.MouseConstraint,
88
Mouse = Matter.Mouse,
9-
World = Matter.World,
9+
Composite = Matter.Composite,
1010
Bodies = Matter.Bodies;
1111

1212
// create engine
@@ -31,7 +31,7 @@ Example.airFriction = function() {
3131
Runner.run(runner, engine);
3232

3333
// add bodies
34-
World.add(world, [
34+
Composite.add(world, [
3535
// falling blocks
3636
Bodies.rectangle(200, 100, 60, 60, { frictionAir: 0.001 }),
3737
Bodies.rectangle(400, 100, 60, 60, { frictionAir: 0.05 }),
@@ -56,7 +56,7 @@ Example.airFriction = function() {
5656
}
5757
});
5858

59-
World.add(world, mouseConstraint);
59+
Composite.add(world, mouseConstraint);
6060

6161
// keep the mouse in sync with rendering
6262
render.mouse = mouse;

examples/avalanche.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Example.avalanche = function() {
2121
Common = Matter.Common,
2222
MouseConstraint = Matter.MouseConstraint,
2323
Mouse = Matter.Mouse,
24-
World = Matter.World,
2524
Bodies = Matter.Bodies;
2625

2726
// create engine
@@ -50,9 +49,9 @@ Example.avalanche = function() {
5049
return Bodies.circle(x, y, Common.random(10, 20), { friction: 0.00001, restitution: 0.5, density: 0.001 });
5150
});
5251

53-
World.add(world, stack);
52+
Composite.add(world, stack);
5453

55-
World.add(world, [
54+
Composite.add(world, [
5655
Bodies.rectangle(200, 150, 700, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
5756
Bodies.rectangle(500, 350, 700, 20, { isStatic: true, angle: -Math.PI * 0.06, render: { fillStyle: '#060a19' } }),
5857
Bodies.rectangle(340, 580, 700, 20, { isStatic: true, angle: Math.PI * 0.04, render: { fillStyle: '#060a19' } })
@@ -70,7 +69,7 @@ Example.avalanche = function() {
7069
}
7170
});
7271

73-
World.add(world, mouseConstraint);
72+
Composite.add(world, mouseConstraint);
7473

7574
// keep the mouse in sync with rendering
7675
render.mouse = mouse;

examples/ballPool.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Example.ballPool = function() {
2121
Common = Matter.Common,
2222
MouseConstraint = Matter.MouseConstraint,
2323
Mouse = Matter.Mouse,
24-
World = Matter.World,
2524
Bodies = Matter.Bodies;
2625

2726
// create engine
@@ -46,15 +45,15 @@ Example.ballPool = function() {
4645
Runner.run(runner, engine);
4746

4847
// add bodies
49-
World.add(world, [
48+
Composite.add(world, [
5049
Bodies.rectangle(400, 600, 1200, 50.5, { isStatic: true, render: { fillStyle: '#060a19' } })
5150
]);
5251

5352
var stack = Composites.stack(100, 0, 10, 8, 10, 10, function(x, y) {
5453
return Bodies.circle(x, y, Common.random(15, 30), { restitution: 0.6, friction: 0.1 });
5554
});
5655

57-
World.add(world, [
56+
Composite.add(world, [
5857
stack,
5958
Bodies.polygon(200, 460, 3, 60),
6059
Bodies.polygon(400, 460, 5, 60),
@@ -73,7 +72,7 @@ Example.ballPool = function() {
7372
}
7473
});
7574

76-
World.add(world, mouseConstraint);
75+
Composite.add(world, mouseConstraint);
7776

7877
// keep the mouse in sync with rendering
7978
render.mouse = mouse;

examples/bridge.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Example.bridge = function() {
1010
Constraint = Matter.Constraint,
1111
MouseConstraint = Matter.MouseConstraint,
1212
Mouse = Matter.Mouse,
13-
World = Matter.World,
13+
Composite = Matter.Composite,
1414
Bodies = Matter.Bodies;
1515

1616
// create engine
@@ -61,7 +61,7 @@ Example.bridge = function() {
6161
return Bodies.rectangle(x, y, 50, 50, Common.random(20, 40));
6262
});
6363

64-
World.add(world, [
64+
Composite.add(world, [
6565
bridge,
6666
stack,
6767
Bodies.rectangle(30, 490, 220, 380, {
@@ -100,7 +100,7 @@ Example.bridge = function() {
100100
}
101101
});
102102

103-
World.add(world, mouseConstraint);
103+
Composite.add(world, mouseConstraint);
104104

105105
// keep the mouse in sync with rendering
106106
render.mouse = mouse;

examples/broadphase.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Example.broadphase = function() {
88
Common = Matter.Common,
99
MouseConstraint = Matter.MouseConstraint,
1010
Mouse = Matter.Mouse,
11-
World = Matter.World,
11+
Composite = Matter.Composite,
1212
Bodies = Matter.Bodies;
1313

1414
// create engine
@@ -34,7 +34,7 @@ Example.broadphase = function() {
3434
Runner.run(runner, engine);
3535

3636
// add bodies
37-
World.add(world, [
37+
Composite.add(world, [
3838
// walls
3939
Bodies.rectangle(400, 0, 800, 50, { isStatic: true }),
4040
Bodies.rectangle(400, 600, 800, 50, { isStatic: true }),
@@ -57,7 +57,7 @@ Example.broadphase = function() {
5757
}
5858
});
5959

60-
World.add(world, stack);
60+
Composite.add(world, stack);
6161

6262
// add mouse control
6363
var mouse = Mouse.create(render.canvas),
@@ -71,7 +71,7 @@ Example.broadphase = function() {
7171
}
7272
});
7373

74-
World.add(world, mouseConstraint);
74+
Composite.add(world, mouseConstraint);
7575

7676
// keep the mouse in sync with rendering
7777
render.mouse = mouse;

examples/car.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Example.car = function() {
77
Composites = Matter.Composites,
88
MouseConstraint = Matter.MouseConstraint,
99
Mouse = Matter.Mouse,
10-
World = Matter.World,
10+
Composite = Matter.Composite,
1111
Bodies = Matter.Bodies;
1212

1313
// create engine
@@ -33,7 +33,7 @@ Example.car = function() {
3333
Runner.run(runner, engine);
3434

3535
// add bodies
36-
World.add(world, [
36+
Composite.add(world, [
3737
// walls
3838
Bodies.rectangle(400, 0, 800, 50, { isStatic: true }),
3939
Bodies.rectangle(400, 600, 800, 50, { isStatic: true }),
@@ -43,12 +43,12 @@ Example.car = function() {
4343

4444
// see car function defined later in this file
4545
var scale = 0.9;
46-
World.add(world, Example.car.car(150, 100, 150 * scale, 30 * scale, 30 * scale));
46+
Composite.add(world, Example.car.car(150, 100, 150 * scale, 30 * scale, 30 * scale));
4747

4848
scale = 0.8;
49-
World.add(world, Example.car.car(350, 300, 150 * scale, 30 * scale, 30 * scale));
49+
Composite.add(world, Example.car.car(350, 300, 150 * scale, 30 * scale, 30 * scale));
5050

51-
World.add(world, [
51+
Composite.add(world, [
5252
Bodies.rectangle(200, 150, 400, 20, { isStatic: true, angle: Math.PI * 0.06, render: { fillStyle: '#060a19' }}),
5353
Bodies.rectangle(500, 350, 650, 20, { isStatic: true, angle: -Math.PI * 0.06, render: { fillStyle: '#060a19' }}),
5454
Bodies.rectangle(300, 560, 600, 20, { isStatic: true, angle: Math.PI * 0.04, render: { fillStyle: '#060a19' }})
@@ -66,7 +66,7 @@ Example.car = function() {
6666
}
6767
});
6868

69-
World.add(world, mouseConstraint);
69+
Composite.add(world, mouseConstraint);
7070

7171
// keep the mouse in sync with rendering
7272
render.mouse = mouse;

examples/catapult.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Example.catapult = function() {
88
Constraint = Matter.Constraint,
99
MouseConstraint = Matter.MouseConstraint,
1010
Mouse = Matter.Mouse,
11-
World = Matter.World,
11+
Composite = Matter.Composite,
1212
Bodies = Matter.Bodies,
1313
Body = Matter.Body,
1414
Vector = Matter.Vector;
@@ -45,7 +45,7 @@ Example.catapult = function() {
4545

4646
var catapult = Bodies.rectangle(400, 520, 320, 20, { collisionFilter: { group: group } });
4747

48-
World.add(world, [
48+
Composite.add(world, [
4949
stack,
5050
catapult,
5151
Bodies.rectangle(400, 600, 800, 50.5, { isStatic: true, render: { fillStyle: '#060a19' } }),
@@ -72,7 +72,7 @@ Example.catapult = function() {
7272
}
7373
});
7474

75-
World.add(world, mouseConstraint);
75+
Composite.add(world, mouseConstraint);
7676

7777
// keep the mouse in sync with rendering
7878
render.mouse = mouse;

examples/chains.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Example.chains = function() {
1010
Constraint = Matter.Constraint,
1111
MouseConstraint = Matter.MouseConstraint,
1212
Mouse = Matter.Mouse,
13-
World = Matter.World,
1413
Bodies = Matter.Bodies;
1514

1615
// create engine
@@ -79,7 +78,7 @@ Example.chains = function() {
7978
stiffness: 0.5
8079
}));
8180

82-
World.add(world, [
81+
Composite.add(world, [
8382
ropeA,
8483
ropeB,
8584
ropeC,
@@ -98,7 +97,7 @@ Example.chains = function() {
9897
}
9998
});
10099

101-
World.add(world, mouseConstraint);
100+
Composite.add(world, mouseConstraint);
102101

103102
// keep the mouse in sync with rendering
104103
render.mouse = mouse;

examples/circleStack.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Example.circleStack = function() {
77
Composites = Matter.Composites,
88
MouseConstraint = Matter.MouseConstraint,
99
Mouse = Matter.Mouse,
10-
World = Matter.World,
10+
Composite = Matter.Composite,
1111
Bodies = Matter.Bodies;
1212

1313
// create engine
@@ -36,7 +36,7 @@ Example.circleStack = function() {
3636
return Bodies.circle(x, y, 20);
3737
});
3838

39-
World.add(world, [
39+
Composite.add(world, [
4040
// walls
4141
Bodies.rectangle(400, 0, 800, 50, { isStatic: true }),
4242
Bodies.rectangle(400, 600, 800, 50, { isStatic: true }),
@@ -57,7 +57,7 @@ Example.circleStack = function() {
5757
}
5858
});
5959

60-
World.add(world, mouseConstraint);
60+
Composite.add(world, mouseConstraint);
6161

6262
// keep the mouse in sync with rendering
6363
render.mouse = mouse;

examples/cloth.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Example.cloth = function() {
88
Composites = Matter.Composites,
99
MouseConstraint = Matter.MouseConstraint,
1010
Mouse = Matter.Mouse,
11-
World = Matter.World,
11+
Composite = Matter.Composite,
1212
Bodies = Matter.Bodies;
1313

1414
// create engine
@@ -38,7 +38,7 @@ Example.cloth = function() {
3838
cloth.bodies[i].isStatic = true;
3939
}
4040

41-
World.add(world, [
41+
Composite.add(world, [
4242
cloth,
4343
Bodies.circle(300, 500, 80, { isStatic: true, render: { fillStyle: '#060a19' }}),
4444
Bodies.rectangle(500, 480, 80, 80, { isStatic: true, render: { fillStyle: '#060a19' }}),
@@ -57,7 +57,7 @@ Example.cloth = function() {
5757
}
5858
});
5959

60-
World.add(world, mouseConstraint);
60+
Composite.add(world, mouseConstraint);
6161

6262
// keep the mouse in sync with rendering
6363
render.mouse = mouse;

0 commit comments

Comments
 (0)