cpSpaceHashEach - 同一行有 2 个问题
我正在尝试掌握花栗鼠的基础知识。在一些教程中我发现了一行:
cpSpaceHashEach(space->activeShapes, &updateShape, nil);
但我在这里遇到了 2 个错误:
1)隐式声明函数在 C99 中无效
2)“struct cpSpace”中没有名为“activeShapes”的成员
有什么问题?为什么不起作用?我还需要添加其他内容吗?
I'm trying to grasp basics of Chipmunk. In some tutorial I found a line:
cpSpaceHashEach(space->activeShapes, &updateShape, nil);
But I get 2 mistakes here:
1) Implicit declaration of function is invalid in C99
2) No member named 'activeShapes' in 'struct cpSpace'
What is wrong? Why doesn't it work? Do I need to include something else?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是为了澄清一些代码,以防其他人遇到此问题,而不是
使用:
显然,此更改已完成,因此更容易保持代码面向未来,因为 activeShapes 并不意味着以这种方式使用。
Just to clarify with some code in case anyone else runs into this problem, instead of
you'd use:
Apparently this change was done so it is easier to keep the code future-proof since the activeShapes were not meant to be used in this way.
深入研究变更日志:(https://github.com/slembcke/Chipmunk-Physics/blob/master/VERSION.txt)
如果您查看,您会发现在 Chipmunk 5.x cpSpace 中。*形状被标记为私有标头中 cpSpace 结构的成员。然后,在 Chipmunk 6.x 中,默认情况下禁用私有访问,并且出现了 cpSpaceEachShape() 函数,它几乎完全取代了您尝试执行的 cpSpaceHashEach() + cpSpace.activeShapes。
Digging into the changelog: (https://github.com/slembcke/Chipmunk-Physics/blob/master/VERSION.txt)
If you look, you'll find that in Chipmunk 5.x cpSpace.*Shapes were marked as private members of the cpSpace struct in the header. Then, in Chipmunk 6.x, private access was disabled by default and a cpSpaceEachShape() function appeared that almost exactly replaced cpSpaceHashEach() + cpSpace.activeShapes that you are trying to do.