版本:Cocos Creator 3.3.2
平台:Web
我想实现一个TiledMap的动态加载,于是我使用了下面这样的代码
let scene = <Node><any>director.getScene().getChildByName('Canvas')
let node = instantiate(this.stage)
this._map = node.getChildByName('map').getComponent(TiledMap)
this._loadMap().then(map => {
this._map.tmxAsset = map
return this._initMap()
})
.then(() => {
node.getChildByName('hero').setPosition(0, 0, 0)
node.parent = scene
node.setPosition(0, 0, 0)
console.log('spawn')
})
map节点里原先有一个空的TiledMap组件
场景加载之后发现Layers是空的QAQ
求各位大神解答!

