当前位置:网站首页>Cocoscreator event dispatch use
Cocoscreator event dispatch use
2022-07-04 17:30:00 【RemoteDev】
1. Event dispatch event mechanism : Based on the event bubble , From the bottom node , Distribute it layer by layer
Such as the current node A Yes 1 Word node , Has child nodes B, and B Nodes have child nodes C
Then the distribution direction of the event is C--->B--->A
Child node C Dispatch incident XXX, Its father's Day B Get the event first XXX control power , Deal with the incident , Then send it to B Parent node A, It can also be dispensed , Call directly
event.propagationStopped = true;
To stop event delivery . such A The node will not receive XXX event .
Node dispatch events : this.node.dispatchEvent( Here you pass in the custom event class )
For the custom event class, refer to the following code :
// Event from cc Module import
import { Event } from 'cc';
// Class inheritance Event
class MyEvent extends Event {
// Pass in the event name and bubble parameter when constructing , The last parameter is the additional information of the event
constructor(name: string, bubbles?: boolean, detail?: any) {
super(name, bubbles);
this.detail = detail;
}
public detail: any = null; // Custom properties
}
Example of node event dispatch : this.node.dispatchEvent(new MyEvent('XXX',true,' Event additional messages '));
2. Dispatch event handling : Call directly on To deal with it
Call on the upper node of the dispatch event node on(' Event name ',( Event object )=>{});
Dispatch event processing example : this.node.on('XXX',(Event:eventObj)=>{});
3. In one sentence, simply understand the event distribution : Child node dispatchEvent Parent node on
边栏推荐
- Zhijieyun - meta universe comprehensive solution service provider
- 解读数据安全治理能力评估框架2.0,第四批DSG评估征集中
- R language plot visualization: plot visualizes overlapping histograms and uses geom at the top edge of the histogram_ The rug function adds marginal rug plots
- 周大福践行「百周年承诺」,真诚服务推动绿色环保
- The company needs to be monitored. How do ZABBIX and Prometheus choose? That's the right choice!
- Is it safe for Bank of China Securities to open an account online?
- Two methods of MD5 encryption
- Learn more about the basic situation of 2022pmp examination
- 世界环境日 | 周大福用心服务推动减碳环保
- 居家打工年入800多万,一共五份全职工作,他还有时间打游戏
猜你喜欢
智慧物流園區供應鏈管理系統解决方案:數智化供應鏈賦能物流運輸行業供應鏈新模式
C# 更加优质的操作MongoDB数据库
detectron2安装方法
Ble HCI flow control mechanism
利用win10计划任务程序定时自动运行jar包
Readis configuration and optimization of NoSQL (final chapter)
Vb无法访问数据库stocks
Chow Tai Fook fulfills the "centenary commitment" and sincerely serves to promote green environmental protection
公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!
CANN算子:利用迭代器高效实现Tensor数据切割分块处理
随机推荐
What grade does Anxin securities belong to? Is it safe to open an account
Years of training, towards Kata 3.0! Enter the safe container experience out of the box | dragon lizard Technology
Datakit -- the real unified observability agent
Solution du système de gestion de la chaîne d'approvisionnement du parc logistique intelligent
VB cannot access database stocks
容器环境minor gc异常频繁分析
【Go ~ 0到1 】 第六天 文件的读写与创建
Summary of tx.origin security issues
Developers, MySQL column finish, help you easily from installation to entry
Implementation of super large-scale warehouse clusters in large commercial banks
NFT流动性市场安全问题频发—NFT交易平台Quixotic被黑事件分析
被PMP考试“折磨”出来的考试心得,值得你一览
将Opencv绘制图片显示在MFC Picture Control控件上
Using win10 scheduling task program to automatically run jar package at fixed time
What are cache penetration, cache breakdown, and cache avalanche
Is it safe for Great Wall Securities to open an account? How to open a securities account
The winning rate against people is 84%, and deepmind AI has reached the level of human experts in army chess for the first time
整理混乱的头文件,我用include what you use
防火墙基础透明模式部署和双机热备
【Unity UGUI】ScrollRect 动态缩放格子大小,自动定位到中间的格子