Drawing downloaded image

Drawing downloaded image
0.0 0


I’m trying to draw the image downloaded by CCHttpRequest but getting runtime errors

after getting 200 (OK) status code

std::vector* buffer = response->getResponseData();
CCImage* image;
image->initWithImageData(buffer->data(), buffer->size()); // EXC_BAD_ACCESS code=2
CCTexture2D* texture;


because your image is an invalid pointer. You must be doing CCImage* image = new CCImage();.


This is the first time i am creating objects without static methods using cocos2d-x. i really forgot to initialize pointers. Thanks.

CCImage* image = new CCImage();
CCTexture2D* texture = new CCTexture2D();

std::vector *buffer = response->getResponseData();
image->initWithImageData(buffer->data(), buffer->size());
userImage = CCSprite::createWithTexture(texture);