Box2D added to Cocos2D errors

Apprentice
Posts: 8
Joined: 2010.11
Post: #1
Hello,

I've just added box2d to my project and now I have errors that say:
"Invalid conversion from 'int' to 'BalloonType'
and
"Cannot initialize a parameter of typ 'BalloonType' with an lvalue of type 'int'"
at the Balloon alloc line.
My project is cocos2d v2 made with the Box2d template.
I hope this is enough information.
Would someone please help me to understand and fix this?
Thanks in advance for your help!
Code:
// .h file:
typedef enum {
    BalloonTypeBlue = 0,
    BalloonTypeOrange = 1,
    BalloonTypePink = 2,
    BalloonTypePurple = 3,
    BalloonTypeYellow = 4    
} BalloonType;

// .m file:
Balloon *balloon = [[[Balloon alloc] initWithBalloonType:balloonType veer:veer] autorelease];
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
balloonType is not a BalloonType? You haven't really posted enough to diagnose. Is it an mm file? C++ is stricter than C about this kind of thing.
Quote this message in a reply
Apprentice
Posts: 8
Joined: 2010.11
Post: #3
I got it figured out. I added .mm to ALL all my implementation files and put ./ in the 'User Header Search Path' for the Build Settings.

I appreciate your time!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Well, that was a big hammer to use :/
Quote this message in a reply
Apprentice
Posts: 7
Joined: 2010.12
Post: #5
If you're interested in doing this a different way, I've built Objective-C static frameworks for both Cocos2D and Box2D that avoid having to include all the source in your project. And in the case of the Box2D wrapper (which I adapted from someone else's), all the C++ is hidden so you can include and compile as normal Objective-C, not Objective-C++. All the C++ ivars are declared in the implementation file, not in the headers. Contributions welcome!

https://github.com/bgulanowski/CCBox2D
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Some trouble with Box2D, recommendations requested TomorrowPlusX 12 14,452 Mar 14, 2011 07:15 PM
Last Post: TomorrowPlusX