精灵变灰
发布时间:2020-12-14 19:31:26 所属栏目:百科 来源:网络整理
导读:// 精灵变灰 Sprite * CUserData ::MakeSpiteGray( * ChangeSprite) { Sprite * sprite_chess = :: createWithSpriteFrame (ChangeSprite- getSpriteFrame ()); sprite_chess- setPosition (sprite_chess- getContentSize (). width /2,sprite_chess- height
//
精灵变灰
Sprite * CUserData ::MakeSpiteGray( * ChangeSprite) { Sprite * sprite_chess = :: createWithSpriteFrame (ChangeSprite-> getSpriteFrame ()); sprite_chess-> setPosition (sprite_chess-> getContentSize (). width /2,sprite_chess-> height /2); RenderTexture *render = create (sprite_chess-> getContentSize (). width ,sprite_chess-> height Texture2D PixelFormat RGBA8888 ); render-> beginWithClear (0.0f,0.0f,0.0f); visit (); end Director getInstance ()-> getRenderer render Image *finalImage = render-> newImage unsigned char *pData = finalImage-> getData int iIndex = 0; for ( i = 0; i < finalImage-> getHeight (); i ++) { j = 0; j < finalImage-> getWidth (); j ++) { // gray iBPos = iIndex; iB = pData[iIndex]; iIndex ++; iG = pData[iIndex]; iR = pData[iIndex]; iGray = 0.3 * iR + 0.6 * iG + 0.1 * iB; pData[iBPos] = pData[iBPos + 1] = pData[iBPos + 2] = ( )iGray; } } Texture2D *texture = new ; texture-> initWithImage (finalImage); auto pSprite = :: createWithTexture (texture); delete finalImage; release return pSprite; } http://www.cocoachina.com/bbs/read.php?tid=219268
如果是用的散图,就简单多了,直接new Image;在调用initwithfile("xx.png"),然后getData(),后面代码一样了; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 指尖上的电商---(6)solrconfig.xml配置详解
- c# – MoQ:属性已正确设置为虚拟但在非虚拟成员上仍设置无
- Oracle数据库中基本的查询优化与子查询优化讲解
- cocos2dx 移植到android失败,log提示no jni_onload found
- Seam中细粒度配置文件(*.page.xml)的<param >理解
- Assembly line / Pipeline
- Greenplum删除segment节点
- UIKit框架-高级控件Swift版本: 2.UITableView方法/属性详解
- 【软件周刊第 30 期】PostgreSQL 10 首个公测版发布;Eclip
- xcode – UITapGestureRecognizer与didSelectRowAtIndexPat
推荐文章
站长推荐
- flex 如何转换数据库中的时间格式,并写到datagr
- c# – 为什么我不能在HTTP响应头中设置“允许”?
- c – 为什么`1 << 32`和`int i = 32; 1 <&l
- ruby-on-rails – 带有导轨的把手/胡须url_for
- c# – 我们可以使用Application Domain执行批处理
- iphone – 如何添加uiimagepickerview自定义叠加
- ruby-on-rails – 在EC2上部署Rails应用程序
- Ruby的“开放类”是否破解封装?
- c# – Asp.net身份终止会话Cookie
- ruby-on-rails – 安装Rails 4.2.0.beta1 – Bun
热点阅读