Skip to content

Commit 8cf216a

Browse files
committed
New PhysicsManager Scene system
1 parent b769e2c commit 8cf216a

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

v3/src/plugins/PhysicsManager.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
var Class = require('../utils/Class');
2+
var NOOP = require('../utils/NOOP');
3+
var Physics = require('../physics');
4+
5+
var PhysicsManager = new Class({
6+
7+
initialize:
8+
9+
function PhysicsManager (scene)
10+
{
11+
this.scene = scene;
12+
13+
// Game level config to start with, then add Scene level config override
14+
this.config = scene.sys.game.config.physics;
15+
16+
this.world = { update: NOOP };
17+
18+
this.add;
19+
},
20+
21+
boot: function ()
22+
{
23+
var config = this.config;
24+
25+
if (!config)
26+
{
27+
return;
28+
}
29+
30+
if (config.system === 'impact')
31+
{
32+
this.world = new Physics.Impact.World(this.scene, config.gravity, config.cellSize);
33+
this.add = new Physics.Impact.Factory(this.world);
34+
}
35+
},
36+
37+
update: function (time, delta)
38+
{
39+
this.world.update(time, delta);
40+
}
41+
42+
});
43+
44+
module.exports = PhysicsManager;

0 commit comments

Comments
 (0)