I am following the instructions in http://www.cocos2d-x.org/projects/cocos2d-x/wiki/How_to_use_CCHttpClient.
I want to download image from the url. For that how do I use the HttpResponse~~>getResponseData?
Because HttpResponse~~>getResponseData() returns a vector, how can I read it into a ccImage object ?
cocos2d::CCTexture2D* texture ;
texture~~>initWithImage; //in this line I am getting exception
CCSprite* sprite = CCSprite::createWithTexture;
this~~>addChild(sprite, 10);
i have also tried like :
img->initWithImageData(buffer, 2841,CCImage::kFmtPng,160,160,8); but still not getting.
And you are doing the same with CCTexture2D. First create CCImage and CCTexture2D with new operator like CCImage* img = new CCImage(); and then you can init it with initWithImageData. And remember that when you new a CCObject then you need to release it or set autorelease to prevent memory leak.
Oh I see that response~~>getResponseData returns a pointer to vector so you should pass it to init like this: img~~>initWithImageData(&(buffer~~>front), buffer~~>size());