Page 1 of 2
New Project - chipmunk_private.h errors
Posted: Sat Oct 20, 2012 9:22 pm
by jcmeyer5
I just upgraded to cocos2d 2.1b and latest Chipmunk Pro (Trial). I created a stock cocos2d iOS project (no chipmunk). I then dropped in Chipmunk Pro. Build, and all is well (no issues). I then when to ccConfig.h and enabled the CC_ENABLE_CHIPMUNK_INTEGRATION flag (to get the CCPhysicsDebugNode up and running). Now I am getting Semantic issues in several structs - cpConstraint, cpArbiter, cpShape, cpBody, cpSpace. They all have a "No member named xxxxx in struct yyyyy" message, and all point to the chipmunk_private.h file. When I went to look at the errors in, say, cpConstraint, it appears as if the CP_PRIVATE members are causing the issues.
Any advice?
Re: New Project - chipmunk_private.h errors
Posted: Sun Oct 21, 2012 8:24 pm
by jcmeyer5
Okay, so if I go into chipmunk.h and set the CP_ALLOW_PRIVATE_ACCESS flag to 1, the errors disappear, but the screen is blank. Plus, I don't think that this is how it is supposed to work (setting the CP_ALLOW_PRIVATE_ACCESS manually in the chipmunk.h file). All I have in the init is the space init, gravity, and a bounding box for the screen.
Code: Select all
-(id) init {
if( (self=[super init]) ) {
CGSize scrSize = [[CCDirector sharedDirector] winSize];
self.space = [[ChipmunkSpace alloc] init];
self.space.gravity = cpv(0,-1000);
self.space.data = self;
CGRect rect = CGRectMake(0, 0, scrSize.width, scrSize.height);
[self.space addBounds:rect
thickness:10
elasticity:0.5f
friction:1.0f
layers:CP_ALL_LAYERS
group:CP_NO_GROUP
collisionType:nil];
[self addChild:[CCPhysicsDebugNode debugNodeForChipmunkSpace:self.space]];
[self scheduleUpdate];
}
return self;
}
-(void) update:(ccTime)dt {
[self.space step:dt];
}
Re: New Project - chipmunk_private.h errors
Posted: Sun Oct 21, 2012 9:59 pm
by jcmeyer5
Okay, more confusion. I made a stock chipmunk-cocos2d project to see how it is set up. In the ccConfig.h file, the CC_ENABLE_CHIPMUNK_INTEGRATION is set to 0, but the project uses CCPhysicsDebugNode.
Is it because I am using Objective Chipmunk?
Re: New Project - chipmunk_private.h errors
Posted: Mon Oct 22, 2012 10:54 am
by slembcke
Oh. Hrm. I think I see what is going on.
The original version of that code was meant to work seamlessly with either Chipmunk or Objective-Chipmunk. When Riq added it with Cocos2D, he added Box2D support to it too and the CC_ENABLE_CHIPMUNK_INTEGRATION stuff. It was never tested again against Objective-Chipmunk and I haven't used the latest beta really.
Making a patch now.
Re: New Project - chipmunk_private.h errors
Posted: Mon Oct 22, 2012 12:13 pm
by slembcke
Fix pushed here:
https://github.com/slembcke/cocos2d-iph ... ntegration
Patch against the mainline develop-v2 branch here:
http://files.slembcke.net/temp/objectiv ... tion.patch
Unless you are working off of the git version of Cocos2D (you really might as well if you are using the betas IMO), you'll need to use the patch file. Download it somewhere, then cd to wherever the cocos2d directory in your project is (should be a directory named lib from the templates) and type "patch -p1 -i /path/to/the/patch/file"
Re: New Project - chipmunk_private.h errors
Posted: Mon Oct 22, 2012 6:17 pm
by jcmeyer5
Gracias!
Re: New Project - chipmunk_private.h errors
Posted: Mon Dec 17, 2012 10:10 pm
by dangermouse
Hi,
I am building a project in XCode 4.5.2 using the latest cocos2d from git (branch develop-v2) and the ChipmunkPro-Trial-6.1.2. I enabled chipmunk integration in ccConfig.h:
#define CC_ENABLE_CHIPMUNK_INTEGRATION 1
and I am getting the same compiler errors as described above in the original post for this thread. I downloaded your modified cocos2d from git and replaced the cocos2d in my project with it.
I also downloaded the patch you provided and ran it against your fork of cocos2d - I'm not familiar with 'patch', and I got the following prompt, so I answered no to it and all subsequent prompts and it ignored applying the patches.
Bollo:libs rowland$ patch -p1 -i objective-chipmunk-integration.patch
patching file cocos2d/CCPhysicsDebugNode.h
Reversed (or previously applied) patch detected! Assume -R? [n]
Could anyone help me figure out what's breaking this build?
Thanks a bunch,
Rowland
Re: New Project - chipmunk_private.h errors
Posted: Mon Dec 17, 2012 10:27 pm
by slembcke
So I had a section in the latest tutorial I wrote about that. I was about to point you to that, but now it's gone. Hrm. It must have gotten merged out when we were doing revisions. I'll have to rewrite that I guess.
Anyway, the patch I made earlier in this thread was rejected by Riq as it caused issues with his Javascript binding generation. He's using a automated tool that parses the headers and it didn't like the forward declarations I used.
Anyway. The workaround for the moment is that you need to import ObjectiveChipmunk.h before cocos2d.h in any .m file. It's a little awkward, but it works. I haven't really been able to find a better solution.
I think I'm going to ask Riq if he'd be Ok with an OBJECTIVE_CHIPMUNK_INTEGRATION enable. I expect he'll go for it considering the CCPhysicsSprite and CCPhysicsDebugNode classes were originally written for use with Objective-Chipmunk example code.
Re: New Project - chipmunk_private.h errors
Posted: Wed Dec 19, 2012 7:14 pm
by dangermouse
Thanks a bunch, that got me past the compiler errors

I'll keep an eye out for the patch you mentioned adding to the system.
Rowland Smith
Re: New Project - chipmunk_private.h errors
Posted: Sat Dec 29, 2012 1:41 pm
by theisegeberg
I hate to be annoying bumper here.
I've got the paid pro version. I tried to dump in the latest objective chipmunk into cocos2d, and I'm getting the same errors.
Can we get a fix for this that won't break the second we update cocos2d or chipmunk please?
