【问题标题】:Why we prefer to use "CCFollow" instead of "CCCamera" in cocos2d?为什么我们更喜欢在 cocos2d 中使用“CCFollow”而不是“CCCamera”?
【发布时间】:2012-04-12 06:50:18
【问题描述】:

在我的例子中,我正在制作一个 2D 游戏,相机总是跟随我的角色,但是会有场景限制,所以当他几乎靠近场景边界时我必须停止跟随他。我还必须处理相机比例,所以我必须决定是使用 CCFollow::actionWithTarget() 还是 CCCamera。

在 CCCamera.h 中它说:

限制:

- Some nodes, like CCParallaxNode, CCParticle uses world node coordinates, and they won't work properly if you move them (or any of their ancestors)
using the camera.

- It doesn't work on batched nodes like CCSprite objects when they are parented to a CCSpriteBatchNode object.

- It is recommended to use it ONLY if you are going to create 3D effects. For 2D effecs, use the action CCFollow or position/scale/rotate.

最后一句话很有意思,为什么只用在 3D 效果中?似乎 CCCamera 的制作人不推荐它。我知道这是处理相机移动的捷径,但我就是不知道为什么最好不要在 2D 游戏中使用它。

【问题讨论】:

  • 你找人澄清一下吗?我有类似的疑问,很高兴知道你是否解决了这些疑问..

标签: c++ ios cocos2d-iphone


【解决方案1】:

如果您注意到,CCCamera.h 文件还会显示:

Useful to look at the object from different views.
The OpenGL gluLookAt() function is used to locate the
camera.

OpenGL 红皮书中有一篇很好的文章,介绍了相机的工作原理。我的理解是,相机是用来设置初始方向的,然后你通过更新模型矩阵来移动世界(这就是我猜 CCFollow 为你做的事情)。如果您仍然想使用相机,这里有一个答案可能会有所帮助:

moving CCCamera

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-31
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 2012-12-08
    • 2011-03-24
    相关资源
    最近更新 更多