Possible to change the alpha value of certain pixels on iPhone?

[亡魂溺海] 提交于 2019-12-11 07:47:51

问题


Is it possible to change just a portion of a Sprite's alpha in response to user interaction? A good example of what I mean is iFog or iSteam, where the user can wipe "steam" off the iPhone's screen. Swapping images out wouldn't be feasible due to the sheer number of possibilities where the user could touch and move...

For example, say you have a simple app that has a brick wall in the background that has graffiti on it, so there'd be two sprites, one of the brick wall, then one of the graffiti that has a higher z value than the brick wall. Then, based upon where the user touches (assuming their touch controls a sandblaster), some of the graffiti should be removed, but not all of it, which could be accomplished by changing the alpha value on a portion of the graffiti sprite. Is there any way to do this in cocos2d-iphone? Or, do I need to drop down into openGL, and if so, where would be a good place to start my search on how to accomplish this?

Ideally, I'd like to accomplish this on a cocos2d-iphone Sprite, but if it's not possible, where's the best place to start looking?

Thanks in advance, Ben


回答1:


The answer is here: http://www.cocos2d-iphone.org/forum/topic/7921#post-46394

But short answer: You have to override the draw method and resort to openGL methods.

I know this question is old, but it needs an answer anyway.



来源:https://stackoverflow.com/questions/787783/possible-to-change-the-alpha-value-of-certain-pixels-on-iphone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!