当前位置:网站首页>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
边栏推荐
- DataKit——真正的统一可观测性 Agent
- Can you really use MySQL explain?
- Leetcode list summary
- The winning rate against people is 84%, and deepmind AI has reached the level of human experts in army chess for the first time
- Analysis of abnormal frequency of minor GC in container environment
- How to "use" Perl modules in directories that are not in @inc- How do I 'use' a Perl module in a directory not in @INC?
- 【HCIA持续更新】WLAN工作流程概述
- 周大福践行「百周年承诺」,真诚服务推动绿色环保
- C# 更加优质的操作MongoDB数据库
- Implementation of super large-scale warehouse clusters in large commercial banks
猜你喜欢
Years of training, towards Kata 3.0! Enter the safe container experience out of the box | dragon lizard Technology
Blood spitting finishing nanny level series tutorial - play Fiddler bag grabbing tutorial (2) - first meet fiddler, let you have a rational understanding
【华为HCIA持续更新】SDN与FVC
新的职业已经出现,怎么能够停滞不前 ,人社部公布建筑新职业
Using win10 scheduling task program to automatically run jar package at fixed time
Congratulations to Mr. Zhang Pengfei, chief data scientist of artefact, for winning the campaign Asia tech MVP 2022
Solution du système de gestion de la chaîne d'approvisionnement du parc logistique intelligent
How to choose one plus 10 pro and iPhone 13?
wuzhicms代码审计
It's too convenient. You can complete the code release and approval by nailing it!
随机推荐
码农版隐秘的角落:作为开发者最讨厌的5件
PyTorch深度学习快速入门教程
DataKit——真正的统一可观测性 Agent
中信证券网上开户安全吗 开户收费吗
[template] [Luogu p4630] duathlon Triathlon (round square tree)
CocosCreator事件派发使用
安信证券排名 网上开户安全吗
公司要上监控,Zabbix 和 Prometheus 怎么选?这么选准没错!
VSCode修改缩进不成功,一保存就缩进四个空格
go-micro教程 — 第二章 go-micro v3 使用Gin、Etcd
La 18e Conférence internationale de l'IET sur le transport d'électricité en courant alternatif et en courant continu (acdc2022) s'est tenue avec succès en ligne.
Learn more about the basic situation of 2022pmp examination
电子宠物小狗-内部结构是什么?
Is it safe for Bank of China Securities to open an account online?
智慧物流园区供应链管理系统解决方案:数智化供应链赋能物流运输行业供应链新模式
祝贺Artefact首席数据科学家张鹏飞先生荣获 Campaign Asia Tech MVP 2022
矿产行业商业供应链协同系统解决方案:构建数智化供应链平台,保障矿产资源安全供应
将Opencv绘制图片显示在MFC Picture Control控件上
R语言plotly可视化:plotly可视化多分类变量小提琴图(multiple variable violin plot in R with plotly)
Solution du système de gestion de la chaîne d'approvisionnement du parc logistique intelligent