从内存中生成ccsprite

CCImage  image;
unsigned long nSize;
char a[]=”15757775232226656.jpg”;
unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(a, “rb”, &nSize);
image.initWithImageData((void*)pBuffer, nSize, CCImage::kFmtJpg);
CC_SAFE_DELETE(pBuffer);

CCTexture2D* pTexture=CCTextureCache::sharedTextureCache()->addUIImage(&image,”key”);

CCSprite* tSprite=new CCSprite();
CCRect rect = CCRectZero;
rect.size = pTexture->getContentSize();
tSprite->initWithTexture(pTexture, rect);

tSprite->setPosition(ccp(size.width/2,size.height/2));

this->addChild(tSprite,1);

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>