可以更改 iPhone 上某些像素的 alpha 值吗? [英] Possible to change the alpha value of certain pixels on iPhone?

查看:46
本文介绍了可以更改 iPhone 上某些像素的 alpha 值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以仅更改 Sprite 的 alpha 的一部分以响应用户交互?我的意思的一个很好的例子是 iFog 或 iSteam,用户可以在其中擦除 iPhone 屏幕上的蒸汽".由于用户可以触摸和移动的可能性非常多,因此交换图像是不可行的......

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...

例如,假设您有一个简单的应用,其背景中有一面砖墙,上面有涂鸦,所以会有两个精灵,一个是砖墙,一个是涂鸦,其 z 值更高比砖墙值钱.然后,根据用户触摸的位置(假设他们的触摸控制喷砂机),应该删除一些涂鸦,但不是全部,这可以通过更改涂鸦精灵的一部分的 alpha 值来完成.在 cocos2d-iphone 中有没有办法做到这一点?或者,我是否需要进入 openGL,如果需要,从哪里开始搜索如何完成此任务的好地方?

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?

理想情况下,我想在 cocos2d-iphone Sprite 上完成此操作,但如果不可能,从哪里开始寻找最佳位置?

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?

提前致谢,本

推荐答案

答案就在这里:http://www.cocos2d-iphone.org/forum/topic/7921#post-46394

但简短的回答:您必须重写 draw 方法并使用 openGL 方法.

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.

这篇关于可以更改 iPhone 上某些像素的 alpha 值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆