- Creator 版本:3.5.2
- 目标平台: Chrome
功能:
障碍物精灵由远及近,从小到大跑过来,会同时并排出现多个。主精灵需要躲避障碍物
详情:
无论是用setScale 动态修改x,y 控制缩放,还是用缓动的tween.to(scale)。单个创建实例化没问题。如果循环同时创建多个,运行15秒左右就会非常卡。。
代码:
for (let index = 1; index <= comb.length; index++) {
const posx = comb[index];
const posRolation = combRolation[index];
const bd1 = instantiate(this.bd1);
bd1.setScale(0.1, 0.1, 0);
tween(bd1)
.to(2, {scale: new Vec3(1, 1, 0)})
.start();
bd1.setParent(this.node);
bd1.setPosition(posx, Constant.defaultY);
const bdComp = bd1.getComponent(BingDu);
bdComp.show(posRolation);
}
哪位大佬能帮看看。
一帧运行N个创建。会有性能问题。卡无非就是IO Dc问题。其中代码逻辑占用很大。因为CPU处理显示数据占用一大半性能。你这个代码可以分帧。再优化Dc。和缓冲池