hiloteam / Hilo

A Cross-end HTML5 Game development solution
https://hiloteam.github.io/
MIT License
5.93k stars 863 forks source link

LoadQueue getSize 方法无法取到文件的字节数 #87

Closed ling7788 closed 7 years ago

ling7788 commented 7 years ago

demo里,LoadQueue 可以正确使用 getLoaded,getTotal ,但 getSize 都是 0

想了想,可能是以下原因 1.基于js环境,获取文件字节数应该无法实现

  1. 函数 getSize 的核心代码是 source.size ,但资源没有 size 属性,莫非要人为指定?

还是 getSize 使用有什么隐藏条件呢?

06wj commented 7 years ago

是因为1原因,可以人工或通过工具事先写到source的size里,例如:

queue.add([
    {id:'bg', size:100, noCache:true, src:'images/bg.png'},
    {id:'logo', size:100, noCache:true, src:'images/logo.png'},
    {id:'data', size:300, noCache:true, type:'jsonp', src:'http://Hilo.com/jsonp.js'}
]);

教程 http://hiloteam.github.io/tutorial/preload.html