kingBook

导航

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;
    }
}

posted on 2020-08-05 16:52  kingBook  阅读(241)  评论(0编辑  收藏  举报