Cocos creator如何使用onCollisionEnter或者onTriggerEnter

其实使用和unity基本一样,但是代码写法有点不一样,unity的话只用直接写事件函数 onTriggerEnter或者 onCollisionEnter就好,但是cocos不仅要写,还要在start方法里绑定

start() {

this.collider = this.node.getComponent(Collider);

//需要这么用Collider或者是Trigger

this.collider.on('onTriggerEnter', this.onTriggerEnter, this);

}

onTriggerEnter(self) {

}

相关推荐
怣疯knight2 天前
Cocos creator判断节点是否能用的方法
unity·cocos2d
Doc.S3 天前
多无人机任务自定义(基于ZJU-FAST-Lab / EGO-Planner-v2)
游戏引擎·无人机·cocos2d
天途小编3 天前
无人机操控模式解析:美国手、日本手、中国手
游戏引擎·无人机·cocos2d
Unity打怪升级7 天前
【Unity精品源码】Ultimate Character Controller:高级角色控制器完整解决方案
游戏·unity·ue5·游戏引擎·godot·游戏程序·cocos2d
7***n7522 天前
C++在游戏中的Cocos2d-x
游戏·游戏引擎·cocos2d
Marvin_Kai22 天前
Cocos Creator 3.x 实现“粒子特效” 的 点击触发
cocos2d
胡童嘉1 个月前
长沙烈焰鸟网络科技有限公司实习day13日记
功能测试·学习·职场和发展·游戏引擎·cocos2d
神秘的土鸡1 个月前
【CS创世SD NAND征文】为无人机打造可靠数据仓:工业级存储芯片CSNP32GCR01-AOW在飞控系统中的应用实践
嵌入式硬件·游戏引擎·无人机·cocos2d·雷龙
小时候的阳光2 个月前
Cocos Creator 和 Unity 3D 编辑界面字体样式大小调整
unity·cocos2d·字体大小