注意:初始物理引擎的代码必须在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;
}
}
本文介绍如何在Cocos Creator中初始化物理引擎,包括设置物理管理器、重力参数及调试标记等关键步骤。

4162

被折叠的 条评论
为什么被折叠?



