I am new to Cocos creator. I wanted to load several sprites from the resources folder.
I wrote following code by looking at the example that comes with creator.
How do I load multiple sprites?
I know there is some delay in loading the resources so I can’t just call the function multiple times right?
What is the correct way of doing this?
I am also confused about following line, what does it do? Why can’t I call “_loadCallBack” directly?
var loadCallBack = this._loadCallBack.bind(this);
onLoad: function () {
this.initReelSprite(1);
},
initReelSprite: function(spriteId)
{
this._itemSprite = this.getComponent(cc.Sprite);
var loadCallBack = this._loadCallBack.bind(this);
cc.loader.loadRes("SlotSymbols/ap_sym_"+spriteId, cc.SpriteFrame, loadCallBack);
},
_loadCallBack: function (err, res) {
if (err) {
cc.log('Error url [' + err + ']');
return;
}
this._itemSprite.spriteFrame = res;
},