CocosCreator 初始化物理引擎
注意:初始物理引擎的代码必须在onLoad()函数。
const {ccclass, property} = cc._decorator;
@ccclass
export default class InitPhysics extends cc.Component {
onLoad(){
let physicsManager:cc.PhysicsManager=cc.director.getPhysicsManager();
physicsManager.enabled=true;
physicsManager.gravity=new cc.Vec2(0,-3500);
physicsManager.debugDrawFlags=cc.PhysicsManager.DrawBits.e_aabbBit|cc.PhysicsManager.DrawBits.e_jointBit|cc.PhysicsManager.DrawBits.e_shapeBit;
}
}