在外部 iOS 项目中使用 Box2D/Cocos2D
我已按照本文中的说明进行操作,并且一直在工作使用 Cocos2D 没有太多问题。最近,我尝试包含 Box2D 标头来尝试一些物理操作,如下所示:
#import "Box2D.h"
这导致了很多错误,其中 Box2D.h 文件无法包含其余的头文件:
../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:0 ../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:37: error: Box2D/Common/b2Settings.h: No such file or directory
这是第一个错误,其余 23 个错误就像但对于 Box2D.h 中的不同标头。
我已经按照本文中的说明将项目/目标添加到当前项目中,因此我的项目当前如下所示:
另外,我尝试通过选择项目中的所有 .m 文件并将文件类型设置为 sourcecode.cpp.objcpp 来解决此问题,但我不认为这是问题所在。我确信在用户标头搜索路径构建设置下,会添加存储这些标头的文件夹。如果不是,Cocos2D 也将无法编译。
我做错了什么?
I have followed the instructions as per this article and have been working with Cocos2D without much issues. Recently, I tried including the Box2D headers to try some physics like so:
#import "Box2D.h"
This resulted in a lot of errors where the Box2D.h file could not include the rest of the header files:
../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:0 ../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:37: error: Box2D/Common/b2Settings.h: No such file or directory
That's the first error and the rest of the 23 are like that, but for the different headers in Box2D.h.
I have already added the projects/targets to the current project as per the instructions in the article, so my project currently looks like this:
Also, I have attempted to remedy this by selecting all .m files in my project and setting the file type to sourcecode.cpp.objcpp but do not think that this is the issue. I am certain that under the User Header Search Paths build setting, the folders where these headers are stored are added. If it weren't, Cocos2D wouldn't be able to compile either.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道这对其他程序员来说是否显而易见,但我通过检查目标设置中的始终搜索用户路径设置来修复此问题。希望它对其他人有帮助。
I don't know if this is immediately obvious to other programmers, but I fixed this by checking the Always Search User Paths setting in the target settings. Hope it helps someone else.
对我来说另一个解决方案是从目录名称中删除空白字符。例如,如果您的项目文件夹
将其更改为
Another solition for me is removing blank characters from directory names. Forexample if your project folder such as
change it to