Cocos Creator单个资源、多个资源加载

              //加载房间预制
            let path = 'Fish/wbTexture/singleRoomPre'
            cc.loader.loadResDir(path, cc.Prefab, (err, ass2) => { //,
                if (err) console.log('rommSA ERR ' + err)
                else {
                    for (let index = 0; index < ass2.length; index++) {
                        // let name = ass2[index]._name;
                        // this.gameroomPngs[name] = ass2[index];
                        this.gameroomPres.push(ass2[index]);  

                    }
                    for(let i =0;i < ass2.length;i++ ){
                        let _roomItem = cc.instantiate(this.roomItem);
                        _roomItem.active = true;
                        _roomItem.parent = this.content;
                        let roomItem = cc.instantiate(ass2[i]);//要实例化的资源必须是object对象,如果资源在文件夹里是多个,就应该用数组遍历的方式加载//The thing you want to instantiate must be an object//
                        this.roomItem.active = true; 
                        roomItem.parent = _roomItem;
                    }
                    ModuleGameInfo.getInstance().getRoomList(this.serverType, (roomInfo) => {
                        //this.init(roomInfo, game)
                    })
                }
            })

 

你可能感兴趣的:(Cocos,Creator学习)