什么是Chipmunk? (除了是物理引擎) [英] What is Chipmunk? (Apart from being a Physics Engine)

查看:190
本文介绍了什么是Chipmunk? (除了是物理引擎)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这个问题不是一个愚蠢的,因为我害怕它的声音,但它可能仍然是很蠢。



我刚接触Objective-C和Cocoa。事实上,我一般是C的新手。我试图使用 Cocos2d-iPhone 实现iPhone游戏。这是我在Flash之前做的一个游戏,所以我认为这是一个很好的方式来瘦Objective C,可可和cocos2d。



我有一个很大的问题是理解为什么所有的 Chipmunk 代码看起来不同于所有的正常Objective-C东西。例如,有像

  chipmunkBody-> position.x 
pre>

我认为这是



chipmunkBody.position.x 或者 [[chipmunkBody position] x] (可能是错误的例子)。



一直以来,我一直在使用cpVect。 cpVect是相当重要的,但我不能为我的生活弄清楚如何传递它。 CGPoint,没有问题,我可以使指针,在方法中传递它们,什么不是,但第二个我使用cpVect,而是欢迎到Errorville,人口你。



这就是问题,什么是Chipmunk,所以我可以开始了解更多关于使用它。



感谢
-t

解决方案

t使用Chipmunk,但它可能是用C / C ++编写的。这是原因。



编辑:它是用C写的。



chipmunkBody 是一个指向struct的指针,而箭头运算符( - > )是如何访问成员一个struct通过指向C中的struct的指针。


Hopefully, this question isn't a dumb as I fear it sounds, but it may still be pretty dumb.

I'm new to Objective-C, and Cocoa. In fact, I'm completely new to C in general. I'm trying to implement an iPhone game using Cocos2d-iPhone. It's a game I've made before in Flash, so I thought it would be a nice way to lean Objective C, cocoa and cocos2d.

One thing I am having a big problem with is understanding why all the Chipmunk code looks different to all the normal Objective-C stuff. For example, there's stuff like

chipmunkBody->position.x

which I thought would have been

chipmunkBody.position.x or maybe [[chipmunkBody position] x] (bad example maybe).

One way this keeps on biting me in the ass is with cpVect. cpVect is pretty important, but I can't for the life of me figure out how to pass it around. CGPoint, no problem, I can make pointers, pass them around in methods and what not, but the second I use cpVect instead, it's "welcome to Errorville, population you".

So that's the question, what is Chipmunk, so I can start finding out more about working with it.

thanks -t

解决方案

I haven't used Chipmunk, but it's probably written in C/C++. That's the reason.

EDIT: Yup, it's written in C.

chipmunkBody is a pointer to a struct, and the arrow operator (->) is how you access the members of a struct through a pointer to the struct in C.

这篇关于什么是Chipmunk? (除了是物理引擎)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆