想动态加载日志,并1s输出一个结果,应该怎么实现呢?

image

// Learn TypeScript:

// - https://docs.cocos.com/creator/manual/en/scripting/typescript.html

// Learn Attribute:

// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html

// Learn life-cycle callbacks:

// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

import item from “./item”;

@ccclass

export default class NewClass extends cc.Component {

@property(cc.Node)

itemPrefabFather: cc.Node = null;    

@property(cc.Prefab)

itemPrefab: cc.Prefab = null;

@property(cc.Label)

text: cc.Label = null;

// LIFE-CYCLE CALLBACKS:

onLoad () {

    let that = this;

    let logsData = [];

    for(var i = 0;i<1000;i++){

        let newLogsData = {'string':'正在执行日志信息id'+i+"的进度加载~"}

        logsData.push(newLogsData);

    }

    cc.log('加载日志数据:',logsData)

    for(let logItem of logsData){

        let prefabItem = cc.instantiate(that.itemPrefab);

        prefabItem.parent = that.itemPrefabFather;

        prefabItem.getComponent(item).initThisPrefab(logItem)

    }

}

start () {

}

update (dt) {

}

}

分帧,滚动面板,item复用

Cocos Creator 3.8 API - Component 使用定时器