Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

jsb.Downloader下载的资源,怎样加载到内存?

$
0
0

@869421306 写道:

cocos creator 2.2.2
iOS平台
我用下面代码下载远程图片,下载回调成功,用cc.loader.load加载不到资源,下载成功后,怎样把资源加载到内存使用?

    let url = "http://xxx.png";
    let fileName = "xxx.png";
    let fullPath = jsb.fileUtils.getWritablePath() + fileName;
    let downloader = new jsb.Downloader();

    downloader.setOnFileTaskSuccess(() => {
        cc.log("Download file succ");
        cc.loader.load(url, (resource: any) => {
            // TODO
        });
    });

    downloader.setOnTaskError(() => {
        cc.warn("Download " + fileName + " failed")
    });

    downloader.createDownloadFileTask(url, fullPath);

帖子: 3

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles