
调用这个function 可以读取icon(cocos内部的icon),但问题是,我没有办法确保他读取完成了,可以回传讯息,请问promise要怎么写?
ps:texture.loaded可以确认他已读取完,但光是这样,我只能开个schdule一直反覆跑到loaded是true才unschdule
urlToSpriteframe() {
var dataURL = "./favicon.ico" + "?t=" + Date.now();
var img = new Image();
var texture = new cc.Texture2D();
img.src = dataURL;
texture.initWithElement(img);
texture.handleLoadedTexture();
this.sprite.spriteFrame.setTexture(texture)
cc.log("loadingComplete");
}
