Files
cocos4/cocos/3d/framework/physics/physics-system.ts
T
2019-03-11 17:32:16 +08:00

42 lines
840 B
TypeScript

import { PhysicsWorldBase } from '../../physics/api';
import { createPhysicsWorld } from '../../physics/instance';
export class PhysicsSystem {
private _world: PhysicsWorldBase;
private _paused = false;
private _singleStep = false;
constructor () {
this._world = createPhysicsWorld();
}
public setSingleStep (b: boolean) {
this._singleStep = b;
}
public resume () {
this._paused = false;
}
public pause () {
this._paused = true;
}
public update (deltaTime: number) {
if (CC_EDITOR) {
return;
}
if (this._paused) {
return;
}
this._world.step(deltaTime);
if (this._singleStep) {
this._paused = true;
}
}
get world () {
return this._world;
}
}