Hello,
is there a way to embed ressource into the code ? like xpm picture file format
for the xpm i imagine a way but not sure if this is a godd idea for the opitmisation of draw calls and spriteframes
or is there a way to protect the ressourcs (audio, video, picture ) from unpacking ?
Thanks for your replies
gprime
June 26, 2015, 3:28pm
#2
If you want it as part of the code, you could encode the binary into base64 and then store that as a string.
The HTML5 project actually stores the loading images using this method, for example in frameworks/cocos2d-html5/Base64Images.js:
cc._loadingImage = "data:image/gif;base64,R0lGODlhE[...]";
Obviously it’d be different in CPP, but the idea should be the same.
See here:
and
i am trying to load a base64 encoded image string to create a sprite. somewhere there seems to be a mistake though because bool ok always returns false. maybe anybody can help me?
here is the code i’m using:
std::string source = “data:image/png;base64,iVBORw0K……”
int len = 0;
unsigned char buffer;
len = base64Decodesource.c_str, source.length, &buffer);
CCImage img = new CCImage();
bool ok = img->initWithImageData(buffer,len);
It sounds like you don’t want to pass in the meta data at the front like you would in JavaScript, though.
Hope that helps.
its a good idea. you can create spriteframe from buffer also ? if yes, it seems to be good. maybe slow at startup.