我试着做了了一个远端get atlas的程序
读的到plist,但放到atlas就卡住了…怎么放来着?
下图献上程式码
const { ccclass, property } = cc._decorator;
@ccclass
export default class plist_loader extends cc.Component {
plisturl: string = "http://127.0.0.1/Resources/test/sheep.plist";
pngurl: string = "http://127.0.0.1/Resources/test/sheep.png";
spriteAtlas: cc.SpriteAtlas = null;
// plist: plist = null;
png: cc.Texture2D = null;
png_done: boolean = false;
plist_done: boolean = false
start() {
// cc.loader.load(this.pngurl,pli()=>{
var self = this;
cc.loader.load(this.pngurl, (err, texture) => {
cc.loader.load(this.plisturl, (err, plist) => {
if (err) cc.log('error');
self.spriteAtlas = new cc.SpriteAtlas();
self.spriteAtlas.addRef(plist);
self.plist_done = true;
cc.log("aaaaa");
})
if (err) cc.log('error');
self.png = texture;
self.png_done = true;
cc.log("bbb");
})
setTimeout(() => {
cc.log("ccc");
let a = self.spriteAtlas.frames["icon5.png"];
// self.plist.RawTextureFile = self.png
this.node.getComponent(cc.Sprite).spriteFrame = a;
}, 500);
}
// update (dt) {}
}
