任聪聪 2023-11-25 12:40 采纳率: 75%
浏览 12
已结题

cocos2.4在抖音开发者工具中运行无报错,无法生成,预制体弹出框是怎么回事?

img

点击事件

    protected onClick(data:any,type:string): void {
        console.log("点击测试");
        let newData = data; 
        let customEvent = new cc.Event.EventCustom('listening_map_city_prefab_btn_click', true);
        customEvent.detail = newData;//自定义的数据调用处
        customEvent['func_meth_type'] = type;
        this.node.dispatchEvent(customEvent);
    }

监听事件

       that.node.on('listening_map_army_popup_prefab_btn_click', that.showArmyRun, that);

弹出弹出框部分:

private showPopup(data:any){
        console.log("点击城市接受到的数据:",data.detail);
        const that = this;
        const type = data.func_meth_type;
        const the_data = data.detail;
        //显示军团列表弹出框
        if(type ==='zjjd'||type==='zlcc'){
            //整理弹出框的初始节点信息 来自地图城市对象
            that.armyPrefabricatedObject = cc.instantiate(that.army_go_popup);
            that.armyPrefabricatedObject.parent = that.popupFatherNode;
            //生成弹出框预制体并带入自定义参数
            that.armyPrefabricatedObject.getComponent(map_army_go_popup).initThisPrefab(the_data,type);            
        }else{
            switch(type){
                case 'other':
                    //整理弹出框的初始节点信息 来自地图城市对象
                    that.npcPrefabricatedObject = cc.instantiate(that.expedition_popup_msg);
                    that.npcPrefabricatedObject.parent = that.popupFatherNode;
                    //生成弹出框预制体并带入自定义参数
                    that.npcPrefabricatedObject.getComponent(expedition_popup_msg).initThisPrefab(the_data);
                    break;
                case 'my':
                    //整理弹出框的初始节点信息 来自地图城市对象
                    that.myPrefabricatedObject = cc.instantiate(that.our_popup_msg);
                    that.myPrefabricatedObject.parent = that.popupFatherNode;
                    //生成弹出框预制体并带入自定义参数
                    that.myPrefabricatedObject.getComponent(our_popup_msg).initThisPrefab(the_data);
                    break;
                default:
                    //默认接受到信息显示公共确认框,并传递参数实例化公共框  来自弹出框中的对象
                    that.commonPrefabricatedObject = cc.instantiate(that.preCommonPopupObj);
                    that.commonPrefabricatedObject.parent = that.popupFatherNode;
                    //生成弹出框预制体并带入自定义参数
                    that.commonPrefabricatedObject.getComponent(map_common_popup).initThisPrefab(the_data,type);
                    break;
            
            }
        }
    }

  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 12月3日
  • 已采纳回答 11月25日
  • 创建了问题 11月25日

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来