cocos2d屏幕效果
我正在使用 cocos2d 开发 iPhone 游戏。我想实现这样的效果:当我的英雄死亡时,屏幕逐渐变成黑/白/灰。也就是说,所有 UI 元素和游戏精灵的颜色都变成黑/白/灰。谁能告诉我该怎么做?我尝试添加 CCColorLayer 作为遮罩,但这看起来不太好。如果为每个元素添加另一个图像,应用程序的大小将增加一倍。那么还有其他方法可以做到这一点吗?
I am working on my iPhone game using cocos2d. I want to implement the effect: when my hero dies, the screen gradually turns to black/white/grey. That is, all the UI elements and game sprites' color turn black/white/grey. Could anyone tell me how to do that? I have tried to add a CCColorLayer as a mask, but that doesn't look good. And if you add another image for each elements, the size of the app will double. So any other methods to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试过 CCTintby 吗?
http://www.cocos2d-iphone.org/api-ref /0.99.5/interface_c_c_tint_by.html
它通过颜色给精灵着色。您可以在游戏层的每个子级上执行此操作。
Have you tried CCTintby ?
http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_c_c_tint_by.html
It tint's sprites by a colour. You could do it on every child of your gameLayer.
也许您可以将场景渲染为纹理,然后手动将纹理的像素颜色转换为灰色。然后将纹理渲染到屏幕上。
Maybe you can render your scene to a texture and then manually convert the texture's pixels color to gray. Then render the texture to the screen.