当前位置: 首页 > news >正文

可以做多边形背景的网站装饰公司logo图标图片

可以做多边形背景的网站,装饰公司logo图标图片,图片下载网站,用ps做三网站横幅相信很多新手朋友#xff0c;肯定会问#xff0c;CocosCreator 中什么是节点#xff1f;什么是组件#xff1f; 一、什么是组件#xff08;Component#xff09;#xff1f; Cocos Creator 3.8 的工作流程是以组件式开发为核心#xff0c;即以组合而非继承的方式进行游… 相信很多新手朋友肯定会问CocosCreator 中什么是节点什么是组件 一、什么是组件Component Cocos Creator 3.8 的工作流程是以组件式开发为核心即以组合而非继承的方式进行游戏中各种元素的构建被称为组件式架构Entity-Component System。 所有继承自Component的类都称为组件类其对象称为组件组件是由引擎创建组件类必须是 cc 类。 例如 import { Component } from cc;ccclass(MyComponent) class MyComponent extends Component { }二、什么是节点Node 节点是承载组件的实体我们通过将具有各种功能的组件挂载到节点上来让节点具有各式各样的表现和功能。 节点是场景的基础组成单位。节点之间是树状的组织关系每个节点可以有多个子节点。 节点特性 节点包含一组基础属性位移、旋转、缩放节点之间通过一组相对变换关系组织在一起。节点间的更新顺序是逐级更新的子节点的更新依赖于父节点子节点跟随父节点变换。节点上可以添加组件将多个组件与节点关联在一起。 三、组件的创建和销毁 组件的生命周期完全由节点操控与普通类对象不同组件不能由构造函数创建 const component new NewComponent(); // 错误组件无法由构造函数创建组件必须由节点来创建通过如下方法将组件添加到节点上 const newComponent node.addComponent(NewComponent);组件不需要的时候通过如下方法移除指定的组件并将其销毁 node.removeComponent(newComponent)四、组件执行顺序 在同一个节点上的组件执行顺序可以通过设置组件的 executionOrder来实现。 executionOrder 越小该组件相对其它组件就会越先执行。 executionOrder 默认为 0因此设置为负数的话就会在其它默认的组件之前执行。 例如有两个组件 CompA.ts 和 CompB.ts 在main.ts 中使用假如我们希望CompB.ts 优先执行。 CompA.ts 脚本内容 import { _decorator, Component, Node } from cc; const { ccclass, property } _decorator;ccclass(CompA) export class CompA extends Component {onLoad () {console.log(CompA onLoad!);}start () {console.log(CompA start!);}update (deltaTime: number) {console.log(CompA update!);} } ! ![在这里插入图片描述](https://img-blog.csdnimg.cn/29104b5ee1d54909ae82ba227a2e40d6.png#pic_center) CompB.ts 脚本内容 import { _decorator, Component, Node } from cc; const { ccclass, property,executionOrder } _decorator;ccclass(CompB) executionOrder(-1) export class CompB extends Component {onLoad () {console.log(CompB onLoad!);}start () {console.log(CompB start!);}update (deltaTime: number) {console.log(CompB update!);} }main.ts 脚本内容 import { _decorator, Component, log } from cc; const { ccclass, property } _decorator;import { CompB } from ./CompB; import { CompA } from ./CompA;ccclass(main) export class main extends Component {property({type:CompA})private CompA null;property({type:CompB})private CompB null;onLoad() {}start() {}update(deltaTime: number) {} }执行顺序如下 五、 组件的生命周期 Cocos Creator 为组件提供了生命周期的回调函数只需要定义特定的回调函数Creator 会在特定的时期自动执行相关脚本开发者不需要手工调用它们。 按生命周期触发先后回调函数有以下 onLoadonEnablestartupdatelateUpdateonDisableonDestroy 1、onLoad onLoad 回调在脚本初始化阶段回调当节点首次激活时触发。 例如所在的场景被载入或者所在节点被激活的情况下。 在 onLoad 阶段可以保证获取到场景中的其他节点以及节点关联的资源数据。 通常会在 onLoad 阶段去做一些初始化相关的操作。 例如 import { _decorator, CCInteger, Component, EventMouse, input, Node,Label, Sprite, find} from cc;const { ccclass, property,type,integer} _decorator;ccclass(PlayerControl) export class PlayerControl extends Component {property({type:Node,visible:true})node:Node null;property({type:Node,visible:true})nodeChild:Node null;onLoad() {this.nodeChild find(test/sp,this.node);} }2、onEnable 当组件的 enabled 属性从 false 变为 true 时或者所在节点的 active 属性从 false 变为 true 时会激活 onEnable 回调。 倘若节点第一次被创建且 enabled 为 true则会在 onLoad 之后start 之前被调用。 3、start start回调函数会在组件第一次激活前也就是第一次执行update 之前触发。 start 通常用于初始化一些中间状态的数据这些数据可能在 update 时会发生改变并且被频繁的 enable 和 disable。 import { _decorator, CCInteger, Component, EventMouse, input, Node,Label, Sprite, find} from cc;const { ccclass, property,type,integer} _decorator;ccclass(PlayerControl) export class PlayerControl extends Component {property({type:Node,visible:true})node:Node null;property({type:Node,visible:true})nodeChild:Node null;private _timer: number 0.0;onLoad() {this.nodeChild find(test/sp,this.node);}start() {this._timer 1.0; }update(deltaTime: number) {this._timer deltaTime;if(this._timer 10.0){console.log(enabled false );this.enabled false;}}}4、update 游戏开发的一个关键点是在每一帧渲染前更新物体的状态和方位。这些更新操作通常都放在 update 回调中。 import { _decorator, Component, Node } from cc; const { ccclass, property } _decorator;ccclass(PlayerControl) export class PlayerControl extends Component {property({type:Node,visible:true})node:Node null;update (deltaTime: number) {this.node.setPosition(0.0,10.0*deltaTime,0.0);} }5、lateUpdate 如果我们要在动效如动画、粒子、物理等更新后进行一些操作或者在所有组件的 update 都执行完之后才进行其它操作那就需要用到 lateUpdate 回调。 import { _decorator, Component, Node } from cc; const { ccclass, property } _decorator;ccclass(PlayerControl) export class PlayerControl extends Component {property({type:Node,visible:true})node:Node null;lateUpdate (deltaTime: number) {this.node.setPosition(0.0,deltaTime,0.0);} }6、onDisable 当组件的 enabled 属性从 true 变为 false 时或者所在节点的 active 属性从 true 变为 false 时会激活 onDisable 回调。 7、onDestroy 当组件或者所在节点调用了 destroy()则会调用 onDestroy 回调并在当帧结束时统一回收组件。
http://www.dnsts.com.cn/news/253139.html

相关文章:

  • 广告毕业设计作品网站沈阳软件定制开发公司
  • 建站平台外贸无锡做网站排名
  • 万州网站制作公司wordpress修改网站地址
  • 那个网站做二手买卖的网站备案成功后可以改吗
  • 越秀网站建设做好直播运营必备的五大能力
  • 四川建设厅网站 蒋wordpress免登录发文章
  • 让人做网站需要注意什么条件域名续费一般多少钱一年
  • 哪个网站有做视频转场的素材国内优秀网站案例
  • 扬中网站推广导流网站域名过期后续费多长时间生效
  • 万州网站制作一个人怎么做网站
  • 网站开发总结与收获wordpress 房产主题
  • 网站制作百度资源找个网页公司做网站
  • 租一个服务器建网站多少钱go做的网站
  • 帝舵手表官方网站产品线上推广渠道
  • 什么是网站的二级目录app软件开发制作公司电话
  • 用psd做的买书网站网络营销是做什么的工作
  • 企业建站设计电脑版 做网站尺寸
  • 网站建设与推广协议西安网页设计培训机构
  • 网站设计合理西安网站设计
  • 江门网站推广哪家好手机动画制作app免费
  • 用CMS做网站的好处软文营销范文100字
  • 云南住房与建设厅网站个人做百度云下载网站
  • 建设银行企业官方网站服装外贸流程
  • 长沙网站优化外包公司苏州网络维护
  • 香格里拉网站建设高端企业网站报价
  • 做招聘网站赚钱么wordpress标签
  • 微信官方网站首页天元建设集团有限公司董事长
  • 泉州设计网站楚州网站开发
  • 阿里巴巴中文站官网wordpress宝宝模板
  • 网站建设顺德云南省疾控中心最新提示