效果如下:

1.制作一个prefab,然后生成10个加入到一个空节点上,考虑到如果生成的关卡数很大的话,加载prefab的时候肯定会出现卡顿效果,所以在网上找了一个类似分帧加载的方法,每个prefab位置计算可以自己算排列,直接上代码如下:
_initData(){
//创建item
let cb = (i) => {
this._initItemPrefab(i)
};
this._loadPrefabFrame('item', 2, this._itemLength, cb);
}
_loadPrefabFrame(name, limit, max, cb) {
let count = 0;
this[name] = () => {
if (count < max) {
for (let i = 0; i < limit; i++) {
count++;
cb && cb(count);
//关闭动画
if (count === max - 1) {
}
}
}
};
this.schedule(this[name], 1 / 60, (max - 1) / limit, 0);
}
private _initItemPrefab(index: number) {
let node

2211

被折叠的 条评论
为什么被折叠?



