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

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日