我做了一个球,一个方块,相应的组件都有放上,球会往右移动,碰到方块,可是没有触发碰撞回调,想请问是哪边出错了。
球脚本
const {ccclass, property} = cc._decorator;`
@ccclass
export default class Ball extends cc.Component {
manager:cc.CollisionManager;
onLoad() {
// init logic
this.manager = cc.director.getCollisionManager();
this.manager.enabled = true;
this.manager.enabledDebugDraw = true;
this.manager.enabledDrawBoundingBox = true;
}
update(dt){
this.node.x += 10;
}
onCollisionEnter(other, self) {
console.log('5555555');
}
}
方块脚本
const {ccclass, property} = cc._decorator;
@ccclass
export default class Block1 extends cc.Component {
manager:cc.CollisionManager;
onLoad() {
// init logic
this.manager = cc.director.getCollisionManager();
this.manager.enabled = true;
this.manager.enabledDebugDraw = true;
this.manager.enabledDrawBoundingBox = true;
}
onCollisionEnter(other, self) {
console.log('44444444');
}
}
场景脚本
const {ccclass, property} = cc._decorator;
@ccclass
export default class Game extends cc.Component {
manager:cc.CollisionManager;
onLoad() {
// init logic
this.manager = cc.director.getCollisionManager();
this.manager.enabled = true;
this.manager.enabledDebugDraw = true;
this.manager.enabledDrawBoundingBox = true;
}
}
