觉醒时刻
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
juexingshike/assets/FrameWork/Mgr/PhysicsManager.ts

42 lines
1.5 KiB

const { ccclass, property } = cc._decorator;
@ccclass
export default class PhysicsManager extends cc.Component {
@property({ tooltip: "是否启动物理引擎" })
active: boolean = true;
@property({ tooltip: "是否显示包围盒" })
aabb: boolean = true;
@property({ tooltip: "是否显示关节链接线" })
joint: boolean = true;
@property({ tooltip: "是否填充形状" })
shape: boolean = true;
@property({ tooltip: "是否开启鼠标关节,可以拖动动态刚体" })
mouseJoint: boolean = false;
@property({tooltip: "重力" })
gravity: cc.Vec2 = cc.v2(0, -960);
onEnable() {
/**开启或关闭物理系统 */
let physicsManager = cc.director.getPhysicsManager();
physicsManager.enabled = this.active;
if (!this.active) return;
/**设置物理系统重力系统 */
physicsManager.gravity = this.gravity;
/**设置调试标志 */
let drawBits = cc.PhysicsManager.DrawBits;
if (CC_PREVIEW) {
physicsManager.debugDrawFlags =
(this.aabb && drawBits.e_aabbBit) |
(this.shape && drawBits.e_shapeBit) |
(this.joint && drawBits.e_jointBit);
} else {
physicsManager.debugDrawFlags = 0;
}
}
onDisable() {
let physicsManager = cc.director.getPhysicsManager();
physicsManager.debugDrawFlags = 0;
physicsManager.enabled = false;
}
// update (dt) {}
}