使用 Cocos2D 和 Box2D 进行光照和阴影

发布于 2024-12-14 02:48:33 字数 585 浏览 3 评论 0原文

我目前正在开发一款适用于 iPad 和 iPad 的游戏。 iPhone 使用 Cocos2d 和 Box2d。 如果能实现像此视频中那样的照明效果,那就太酷了:

http:// /www.youtube.com/watch?v=Elnpm-gNI04

并在此链接上:

http://www.catalinzima。 com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/

我可以尝试用 Cocos2d 和 Box2d 复制效果根据链接中的描述,但我不确定我是否能够走得很远。它看起来非常先进和沉重。

我怎样才能以“简单”的方式实现这一目标?有谁知道类似这样的 Cocos2d 版本,或者有人能给我指出正确的方向吗?

I am currently developing a game for iPad & iPhone using Cocos2d with Box2d.
It would have been majorly cool to achieve a lighting effect like the one in this video:

http://www.youtube.com/watch?v=Elnpm-gNI04

and on this link:

http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/

I could have a go at trying to replicate the effect with Cocos2d and Box2d from the description in the link, but I am unsure if I would be able to get very far. It looks pretty advanced and heavy.

How can I achieve this in an "easy" way? Does anyone know of a Cocos2d-version of something like this, or do anyone have some pointers to point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

深白境迁sunset 2024-12-21 02:48:33

http://code.google.com/p/box2dlights/
我已经成功制作了使用 box2d 几何和 rayCasting 的动态光源库。我的库在gles1.0和gles2.0下工作并使用libgdx作为框架。这足以为移动设备的 2D 游戏提供动态实时灯光。我可以帮助将其移植到 Cocos2D。基础知识非常简单。当我第一次为自己的游戏破解它时,它还不到 100 行。

例子:
点光源从中心发射n条光线,并记录下最近的碰撞点。这些碰撞点用于使用渐变着色并使用附加混合绘制的网格。

http://code.google.com/p/box2dlights/
I have succesfully made dynamic light library that use box2d geometry and rayCasting. My library work under gles1.0 and gles2.0 and use libgdx as framework. This is peformant enough for giving dynamic real time lights to 2d games for mobile devices. I can help with porting that to Cocos2D. Basics are darn simple. It was under 100 lines when I first hacked it working for my own game.

Example:
Point light shoot from center n number of rays around it and record the closest collision points. These collision points are used for mesh that is colored with gradient and drawed with additive blending.

夏雨凉 2024-12-21 02:48:33

尝试查看此链接。

http://www.cocos2d-iphone.org/forum/topic/27856

他遵循 Catalin Zima 使用的技术,使用 cocos2d + Chipmunk 成功添加了简单的动态光。
请注意,如果您下载他的项目并尝试编译 iOS 构建,然后删除“运行脚本”构建阶段,因为您可能会遇到脚本未找到错误。有关删除此类阶段的更多信息,请参见此处

Try to look at this link.

http://www.cocos2d-iphone.org/forum/topic/27856

He successfully added simple dynamic light using cocos2d + chipmunk following the technique that Catalin Zima used.
Please note if you download his project and try to compile iOS build, then remove "Run Script" build phase as you may experience script didn't found error. More info to remove such phase can be seen here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文