Cocos-2dx精灵部分变灰

Cocos-2dx精灵部分变灰,第1张

概述CCSprite* CCSpotLight::makeSpiteGray(CCSprite* changeSprite){ CCRenderTexture *render = CCRenderTexture::create(changeSprite->getContentSize().width, changeSprite->getContentSize().height,kCCTexture
CCSprite* CCSpotlight::makeSpiteGray(CCSprite* changeSprite){	CCRenderTexture *render = CCRenderTexture::create(changeSprite->getContentSize().wIDth,changeSprite->getContentSize().height,kCCTexture2DPixelFormat_RGBA8888);	render->beginWithClear(0.0f,0.0f,0.0f);	changeSprite->visit();	render->end();	//CCDirector::getInstance()->getRenderer()->render();	CCImage *finalimage = render->newCCImage();	unsigned char *pData = finalimage->getData();	int iIndex = 0;	for (int i = 0; i < finalimage->getHeight(); i ++)	{		if (i >= 100 && i < 200)			continue;		for (int j = 0; j < finalimage->getWIDth(); j ++)		{			if (j >= 50 && j < 100)				continue;			// gray			int iBPos = iIndex;			unsigned int iB = pData[iIndex];			iIndex ++;			unsigned int iG = pData[iIndex];			iIndex ++;			unsigned int iR = pData[iIndex];			iIndex ++;			iIndex ++;			unsigned int iGray = 0.3 * iR + 0.6 * iG + 0.1 * iB;			pData[iBPos] = pData[iBPos + 1] = pData[iBPos + 2] = (unsigned char)iGray;		}	}	CCTexture2D *texture = new CCTexture2D;	texture->initWithImage(finalimage);	auto pSprite = CCSprite::createWithTexture(texture);	delete finalimage;	texture->release();	return pSprite;}
总结

以上是内存溢出为你收集整理的Cocos-2dx精灵部分变灰全部内容,希望文章能够帮你解决Cocos-2dx精灵部分变灰所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1026259.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存