我循环了50个台阶,但是只有首屏的3个台阶被渲染出来了,请问下可能是哪里有问题吗
NewProject.zip (2.5 MB)
generateRoad(){
this._road = [];
for (let i = 0; i < this.roadLength-1; i++) {
let y = -200+370*i
this._road.push(y)
}
for (let j = 0; j < this._road.length; j++) {
let block: Node = this.spawnBlockByType();
block.getComponent(platform).setSpeed(randomNum(10,20))
if (block) {
this.bg.addChild(block);
block.setPosition(randomNum(-100,100), this._road[j], 0);
}
console.log(block.getPosition());
}
}
spawnBlockByType() {
let block = instantiate(this.platformPrfb);
return block;
}
update (deltaTime: number) {
// crmera挂在bg节点下,移动bg节点让屏幕跟随主角
let distance = Math.floor(this.playerCtrl?.node.getPosition().y-this.initPos)-500
if(distance>0)this.bg.setPosition(new Vec3(0,distance,0))
}

