Hi,
I’m using loadRes in onLoad function.
onLoad: function () {
let url = 'prefab/bullet_prefab';
cc.loader.loadRes(url, cc.Prefab,
function (err, prefab) {
if (err) {
cc.error(err.message || err);
return;
};
cc.log('Result should be a prefab: ' + (prefab instanceof cc.Prefab));
this.bullet = cc.instantiate(prefab);
});
}
Then I trying to use the prefab in update.
update: function (dt) {
this.bullet.setPosition(0, 0);
//
}
But loadRes is not finished yet when update started.
How can I make update wait until loadRes ended?
Thanks.