Open hsdk123 opened 10 years ago
I think a better approach would be: adding a hook for deciphering file data immediately after having retrieved bytes from xhr
.
because:
nwsnapshot
, but code in the framework is published, thus unprotected.) function(bytes){ return bytes.map(function(byte){ return (byte + 45) % 256; });}
, if protected.Hi, here's the plan:
cc.loader.loadImg()
work through xhr(arraybuffer) => blob => blob url => HTMLImage
(instead of directly using HTMLImage, this could also bring possibilities for tracking load progress for eg. cc.LoaderScene.preload()
)cc.loader.loadTxt()
load arraybuffer
, then convert the result to string. ( http://stackoverflow.com/questions/6965107/converting-between-strings-and-arraybuffers )loadFont/loadAudio
are similar to 1. , xhr(arraybuffer) => blob => blob url => ... releventHTMLTags
cc.loader.handlingResourceBuffer
default to function(bufferArray){ return bufferArray; }
. It can be overridden by users.template/src/resource.js
. (for overriding cc.loader.handlingResourceBuffer
)if it's ok, I'll try to make a patch. @dingpinglv
@layerssss Thanks for the replies, that would seem to do the trick. I'll let you know if it works after the patch.
I noticed the compression related files in cocos2d-html5 - I feel it would be great if decompression of password protected zip files would be added as a feature.
This would be a big help for ex. node-webkit cocos2d-html5 applications that need graphics, music resources protected from normal players.