温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

[cocos2d-x]将合成的图片中的某一个图大批量的加载到图层中

发布时间:2020-05-22 09:28:16 来源:网络 阅读:543 作者:蓬莱仙羽 栏目:游戏开发
//将合成图片中的某一桢图片大批量的添加到场景中,进行场景的优化  	//方法一: 	//将合成的图片的plist添加到缓存 	/*CCSpriteFrameCache* frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); 	frameCache->addSpriteFramesWithFile("jiji.plist"); 	//获取其中的一个图片给CCSpriteFrame 	CCSpriteFrame*frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("alien.png"); 	//将frame的Texture赋给CCSpriteBatchNode 	CCSpriteBatchNode*batchNode = CCSpriteBatchNode::createWithTexture(frame->getTexture(),100); 	batchNode->setPosition(CCPointZero); 	this->addChild(batchNode);  	for (int i=0;i<1000;i++	) 	{ 	CCSprite *testIcon = CCSprite::createWithSpriteFrameName("alien.png"); 	testIcon->setPosition(ccp(size.x/2,size.y/2 + 60)); 	batchNode->addChild(testIcon); 	}*/ 	 	//方法二:  	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("jiji.plist"); 	CCSpriteBatchNode*batchNode = CCSpriteBatchNode::create("jiji.pvr.ccz"); 	batchNode->setPosition(CCPointZero); 	this->addChild(batchNode);  	for (int i=0;i<10000;i++	) 	{ 		CCSprite *testIcon = CCSprite::createWithSpriteFrameName("alien.png"); 		testIcon->setPosition(ccp(size.x/2,size.y/2 + 60)); 		batchNode->addChild(testIcon); 	}

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI