当前位置:网站首页>Cocos学习日记3——api获取节点、组件
Cocos学习日记3——api获取节点、组件
2022-06-25 06:38:00 【herb.dr】
目录
一、API 获取节点
1.1 原理
1、当前节点 this.node : cc.Node
例如 let node : cc.Node = this.node;
2、父节点 this.node.parent
3、子节点 this.node.children : cc.Node[]
4、全局查找
例如 target = cc.find("Canvas/佩奇/名字")
5、查找子节点
例如 target = cc.find("xx/yy", someNode)
1.2 案例

二、API 获取组件
对于已经节点 node,
可以获取它挂载的组件对象
获取组件
let label = node.getComponent(c.Label)
获取自定义类型的组件(脚本组件)
let script = node.getComponent(' YourScript")


三、脚本组件访问



边栏推荐
- Shell command learning
- Non-contact infrared temperature measurement system for human body based on single chip microcomputer
- 基于 KubeSphere 的分级管理实践
- How to get the difference between two dates rounded to hours
- lotus v1.16.0-rc3 calibnet
- 高效探索|ES地理位置查询的一次应用实践
- The process of making wooden barrels with 3DMAX software: a three-step process
- 终于等到你,小程序开源啦~
- Change the current count of auto increment values in MySQL- Changing the current count of an Auto Increment value in MySQL?
- Using awk to process input from multiple files
猜你喜欢

Reading sensor data with GPIO analog SPI interface

The king scheme in distributed locks - redisson

Display purchase Summary - Dell 2705qm BenQ pd2700u

Finally, when you open source the applet ~

破万,我用了六年!

分布式锁中的王者方案 - Redisson

Atomic alpha development board -- SD card and EMMC burning tool
![[he doesn't mention love, but every word is love]](/img/28/0c3ddad3dc9b1ef8d0618164f39e53.png)
[he doesn't mention love, but every word is love]

【2022黑马程序员】SQL优化

深入解析 Apache BookKeeper 系列:第三篇——读取原理
随机推荐
Why use NoSQL with MySQL?
Understand ZBrush carving software and game modeling analysis
alphassl通配符证书送一个月
有了 MySQL 为什么要用 NoSQL?
Torchserve pit avoidance Guide
Enter an integer with any number of bits, and output the sum of each bit of the number. For example: 1234 – > 10
Change the current count of auto increment values in MySQL- Changing the current count of an Auto Increment value in MySQL?
Changing the background color of tab bar - changing the background color of tab bar
Love Terminator
How do I get red green blue (RGB) and alpha back from a UIColor object?
How is the network connected?
lotus v1.16.0-rc2 Calibration-net
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!
The process of making wooden barrels with 3DMAX software: a three-step process
New research shows that human ability to make decisions and process information does not decline until the age of 60
Icon already includes gloss effects
Loopholes in the missed scanning system of Lvmeng and its repair scheme
我们不一样
Navicat prevent new query from being deleted by mistake
Analysis on the trend of the number of national cinemas, film viewers and average ticket prices in 2021 [figure]