cocos2d-x读取ZIP中的图片名称

unsigned long fZize = 0;
	unsigned char * buff = NULL;
	//获得全部路径
	const char *path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Image.zip");
	//从zip中读取图片数据
	buff = CCFileUtils::sharedFileUtils()->getFileDataFromZip(path,"1.png",&fZize); 
	//创建Image、创建img纹理、创建纹理精灵
	CCImage *img = new CCImage();
	img->initWithImageData(buff,fZize,img->kFmtPng);
	CCTexture2D *texture = new CCTexture2D();
	texture->initWithImage(img);
	CCSprite *sprite = CCSprite::createWithTexture(texture);
	sprite->setPosition(ccp(s.width/2,s.height/2));
	addChild(sprite);

你可能感兴趣的:(C++,Class,iostream,cocos2d-x,cocos2d-x3.x)