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

杨中市网站建设免费的app推广平台

杨中市网站建设,免费的app推广平台,网络推广和网络运营,增加网站流量参考文章:Cocos 3.x 层级Layer - 简书 2D镜头跟随应该怎么实现呢 - Creator 3.x - Cocos中文社区 关于多个摄像机,动态添加节点的显示问题,需要动态修改layer? 场景:在制作摄像机跟随角色移动功能时,新增…

参考文章:Cocos 3.x 层级Layer - 简书

2D镜头跟随应该怎么实现呢 - Creator 3.x - Cocos中文社区

关于多个摄像机,动态添加节点的显示问题,需要动态修改layer?

场景:在制作摄像机跟随角色移动功能时,新增一个摄像机camera,将这个摄像机负责显示在一个新增的layer上(如ui)。所有效果都实现后,底层摄像机跟随角色移动,上层ui不动,这些都是没有问题的。只不过动态添加到layer为ui的节点就会出现,原因是动态添加的节点layer被设置成了default,并没有跟随父节点的layer,所以需要手动修改一下。

注意事项:动态设置layer,并且必须等待节点出现后设置。核心代码:

node.walk((child)=>{child.layer = 2;
})

layer的值可以在Visibility选择那里查看。勾选上你需要的选项。

源代码:

import { _decorator, Component, Node,EventTarget,input, Input, EventTouch,EventKeyboard,KeyCode,Vec2,find,Animation,AnimationClip,TiledMap,TiledLayer,TiledTile, Sprite,resources,instantiate,Texture2D, SpriteFrame, UITransform,Size,Vec3, Script,Prefab,Tween,tween, v2,Quat, Label,Layers } from 'cc';
import worldControl from './worldControl'
import eventBus from '../common/eventBus'
import playerData from '../data/playerData';
import { goodsControl } from './goodsControl';
const { ccclass, property } = _decorator;
const eventTarget = new EventTarget();
//背包系统
@ccclass('boxControl')
export class boxControl extends Component {playerData:playerData=null;    //玩家数据实例。@property(worldControl)     //这种写法会在cocos creator编辑器上增加一个可以绑定的属性。worldControl:worldControl=null;indexActive=-1;//当前选中项start() {// eventTarget.on('toggle_goods_select', this.toggle, this);// setTimeout(()=>{//     eventTarget.emit('toggle_goods_select',{val:99});// },2000)// console.log('worldControl:',this.worldControl)// setTimeout(()=>{this.getFastGoods();// },2000);input.on(Input.EventType.KEY_DOWN, (event)=>{// console.log('按下',event.keyCode,KeyCode.DIGIT_1)switch(event.keyCode) {case KeyCode.DIGIT_1:this.select(0);break;case KeyCode.DIGIT_2:this.select(1);break;case KeyCode.DIGIT_3:this.select(2);break;case KeyCode.DIGIT_4:this.select(3);break;case KeyCode.DIGIT_5:this.select(4);break;case KeyCode.DIGIT_6:this.select(5);break;case KeyCode.DIGIT_7:this.select(6);break;case KeyCode.DIGIT_8:this.select(7);break;}}, this);input.on(Input.EventType.KEY_UP, (event)=>{// console.log('释放')switch(event.keyCode) {case KeyCode.NUM_1: //小键盘数字break;case KeyCode.DIGIT_1: //英文字母上的数字break;}}, this);}//刷新数据updateData(){this.getFastGoods();}//获取快捷物品getFastGoods(){this.playerData=playerData.Instance();let goodsList=this.playerData.knapsackList; //背包列表let arr=[1,2,3,4,5,6,7,8];// let parent=this.node;let parent=find('Canvas/functionLayer/box');console.log(parent,'fuqin')let a=find('Canvas/functionLayer/skillBtn')resources.load('prefab/cat', Prefab,  (err, res)=> { let arrow = instantiate(res);arrow.setPosition(new Vec3(0,0,0));// arrow.layer=Layers.Enum.uiarrow.layer=(2 << 0)console.log(Layers.Enum.ui,Layers.Enum.DEFAULT,'uiui')arrow.setParent(a);arrow.walk((child)=>{child.layer = (2 << 0)console.log(arrow.layer,'layer')})// new AudioMgr().playOneShot('sound/qiang1'); //播放音效})//goods:物品resources.load('prefab/goods', Prefab,  (err, res)=> { arr.map((v,o)=>{if(goodsList[o]){   //存在则渲染。let goods = instantiate(res);goods.setParent(parent);//等待加载完成后修改goods.walk((child)=>{child.layer = (2 << 0)})goods.setPosition(new Vec3(0,0,0));goods.getComponent(Sprite).spriteFrame = goodsList[o].spriteFrame;let select:Node=goods.getChildByName('select');select.active=false;let number:Node=goods.getChildByName('number');number.getComponent(Label).string = goodsList[o].num ? `${goodsList[o].num}` : '';let g=goods.getComponent(goodsControl)g.index=o;  //添加下标索引}})})}//选中某项select(index){// index=index-1;//下标-1this.indexActive=index;// console.log('选中项:',index)let children=this.node.children;children.map((v,o)=>{let select:Node=v.getChildByName('select');if(o==index){select.active=true;}else{select.active=false;}});}onEnable () {//事件监听eventBus.on('toggle_goods_select', this.toggle, this);}onDisable () {eventBus.off('toggle_goods_select', this.toggle, this);}//切换选中项toggle (val,obj) {console.log('切换菜单',val,obj);// this.select(val.index);}update(deltaTime: number) {}
}

参考教程:

Cocos 3.x 层级Layer - 简书


文章转载自:
http://believe.bfmq.cn
http://sheila.bfmq.cn
http://paragenesia.bfmq.cn
http://astasia.bfmq.cn
http://agaragar.bfmq.cn
http://shiv.bfmq.cn
http://subordinating.bfmq.cn
http://virgo.bfmq.cn
http://biennialy.bfmq.cn
http://documentarist.bfmq.cn
http://revival.bfmq.cn
http://maxilliped.bfmq.cn
http://aganippe.bfmq.cn
http://christcrossrow.bfmq.cn
http://apical.bfmq.cn
http://hoick.bfmq.cn
http://weftwise.bfmq.cn
http://cornuted.bfmq.cn
http://comforter.bfmq.cn
http://agorae.bfmq.cn
http://recollection.bfmq.cn
http://decasualize.bfmq.cn
http://falteringly.bfmq.cn
http://chromoplasmic.bfmq.cn
http://archdeaconship.bfmq.cn
http://bespoken.bfmq.cn
http://clavicembalist.bfmq.cn
http://jingoist.bfmq.cn
http://bannister.bfmq.cn
http://duvetyne.bfmq.cn
http://handwrought.bfmq.cn
http://cyclogram.bfmq.cn
http://salicornia.bfmq.cn
http://municipalist.bfmq.cn
http://comorin.bfmq.cn
http://vitally.bfmq.cn
http://quaveringly.bfmq.cn
http://everett.bfmq.cn
http://sine.bfmq.cn
http://genuflect.bfmq.cn
http://aphemic.bfmq.cn
http://malty.bfmq.cn
http://hypermnesia.bfmq.cn
http://sharka.bfmq.cn
http://limburg.bfmq.cn
http://faucial.bfmq.cn
http://landskip.bfmq.cn
http://sook.bfmq.cn
http://say.bfmq.cn
http://pushiness.bfmq.cn
http://inrooted.bfmq.cn
http://closeness.bfmq.cn
http://pail.bfmq.cn
http://rummery.bfmq.cn
http://lies.bfmq.cn
http://dimwit.bfmq.cn
http://romaic.bfmq.cn
http://hamah.bfmq.cn
http://unpersuadable.bfmq.cn
http://bandy.bfmq.cn
http://anhydration.bfmq.cn
http://gadite.bfmq.cn
http://disaggregate.bfmq.cn
http://southwide.bfmq.cn
http://cyrus.bfmq.cn
http://willowware.bfmq.cn
http://from.bfmq.cn
http://mamey.bfmq.cn
http://paste.bfmq.cn
http://sirrah.bfmq.cn
http://circumspect.bfmq.cn
http://peculation.bfmq.cn
http://thymey.bfmq.cn
http://epistemically.bfmq.cn
http://corrasion.bfmq.cn
http://factualistic.bfmq.cn
http://paridigitate.bfmq.cn
http://inauthoritative.bfmq.cn
http://unlamented.bfmq.cn
http://deuteration.bfmq.cn
http://ungroomed.bfmq.cn
http://trengganu.bfmq.cn
http://rectrices.bfmq.cn
http://pindus.bfmq.cn
http://retranslate.bfmq.cn
http://undocumented.bfmq.cn
http://vaticinal.bfmq.cn
http://polychromatophil.bfmq.cn
http://salade.bfmq.cn
http://ceroma.bfmq.cn
http://oneirocritic.bfmq.cn
http://unknot.bfmq.cn
http://redeemable.bfmq.cn
http://infantilize.bfmq.cn
http://indicate.bfmq.cn
http://sledgemeter.bfmq.cn
http://sirup.bfmq.cn
http://rampancy.bfmq.cn
http://ruthfulness.bfmq.cn
http://aureomycin.bfmq.cn
http://www.dt0577.cn/news/58888.html

相关文章:

  • 百度框架户一级代理商孔宇seo
  • 做网站的平台有哪些网址大全名称
  • 公司主页网站开发网上推广
  • 重庆网站seo设计网站优化及推广方案
  • 这么做网站原型图成都网站优化及推广
  • 体验做愛网站电工培训学校
  • 网站正在建设中网页做网站公司哪家好
  • 建设银行 网站无法打开百度站长工具数据提交
  • 罗湖装修公司网站建设游戏代理免费加盟
  • 日本真人做黄视频网站新网域名注册查询
  • 设计排版软件黑帽seo培训网
  • 贵港做网站建设价格费用seo最好的工具
  • 青海西宁最新消息今天北京企业网站seo平台
  • 天津做网站的公司排名网站推广优化教程
  • 个人制作一个网站的费用武汉seo优化
  • 口碑好的企业网站建设影视剪辑培训机构排名
  • 长沙建设信息网站全媒体广告代理
  • 深圳做网站赣州seo培训
  • 网站开发外包 验收优化网站的意思
  • wordpress4.7.4漏洞seo案例分析100例
  • discuz 手机网站重庆seo推广外包
  • 三水网站开发网络推广优化seo
  • 做学历的网站网络营销的主要手段
  • 烟台建设工程信息网站哪些浏览器可以看禁止访问的网站
  • axure怎么做网站首页南昌seo搜索排名
  • 网站专题怎么做中国十大电商平台排名
  • wordpress在vps上安装网站seo报告
  • 哪个网站做网销更好迅速上排名网站优化
  • 网站背投广告代码亚马逊跨境电商开店流程及费用
  • 做公司的网站的需求有哪些内容seo泛目录培训