前辈,我拉了两个精灵,加了下面的脚本,但是始终不触发函数
添加了PhysicsBoxColider,也按照要求分组打勾了 (范例里面不是这个组件名字,应该是1.6有变化)
请问我哪里出错了?
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// default: null, // The default value will be used only when the component attaching
// to a node for the first time
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
cc.director.getCollisionManager().enabled=true;
cc.director.getCollisionManager().enabledDrawBoundingBox = true;
console.log('loaded...');
},
onCollisionEnter: function (other, self) {
//this.node.color = cc.Color.RED;
console.log('on Enter...');
},
onCollisionStay: function (other) {
// console.log('on collision stay');
cc.log('zzz');
},
onCollisionExit: function () {
console.log('zzzzzz');
},
// called every frame, uncomment this function to activate update callback
update: function (dt) {
if ( this.node.name === "left"){
this.node.x++;
}else{
this.node.x--;
}
},
});