小白求助,跟着cocos creator手册做快速上手的游戏遇到问题

刚开始使用cocos没多长时间,在试着跟cocos creator手册上的 快速上手:制作第一个 2D 游戏
但是做到设置 GameManager生成随机地图的时候,发现地图怎么也不显示,查了半天也没找到原因,有点疑惑)
感觉就是一步步跟着教程做的QAQ
下面是GameManager的代码:
import { _decorator, CCInteger, Component, instantiate, Node, Prefab } from ‘cc’;

import { BLOCK_SIZE } from ‘./PlayerController’;

const { ccclass, property } = _decorator;

enum BlockType{

BT_NONE,

BT_STONE,

};

@ccclass(‘GameManager’)

export class GameManager extends Component {

@property({type: Prefab})

public boxPrefab: Prefab|null = null;

@property({type: CCInteger})

public roadLength: number = 50;

private _road: BlockType[] = [];

start() {

    this.generateRoad()

}

update(deltaTime: number) {

   

}

generateRoad() {

    this.node.removeAllChildren();



    this._road = [];

    // startPos

    this._road.push(BlockType.BT_STONE);



    for (let i = 1; i < this.roadLength; i++) {

        if (this._road[i - 1] === BlockType.BT_NONE) {

            this._road.push(BlockType.BT_STONE);

        } else {

            this._road.push(Math.floor(Math.random() * 2));

        }

    }



    for (let j = 0; j < this._road.length; j++) {

        let block: Node | null = this.spawnBlockByType(this._road[j]);

        if (block) {

            this.node.addChild(block);

            block.setPosition(j * BLOCK_SIZE, 0, 0);

        }

    }

}

spawnBlockByType(type: BlockType) {

    if (!this.boxPrefab) {

        return null;

    }



    let block: Node|null = null;

    switch(type) {

        case BlockType.BT_STONE:

            block = instantiate(this.boxPrefab);

            break;

    }
    return block;
}

}
检查了下也已经把预制体放在对应的属性下面了
image
但是出来效果是这样的
image
手册上出来的效果应该是会随机生成道路的
image
总之非常费解,求解答
(以及就是这是第一次发帖,如果有什么格式上或者内容上的表述不妥之类的问题也恳请大家指出!)

image 可能这个?

可以浏览器预览的时候,打一下断点看一下问题

是不是没保存 :smirk_cat:
我用你的代码都有1701335180881

1701336034675 还是说这个错你没管

first step:学会调试