Possible to change the alpha value of certain pixels on iPhone?(可以更改 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 值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:可以更改 iPhone 上某些像素的 alpha 值吗?
基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01