iDevGames Forums

Full Version: Box2D added to Cocos2D errors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I've just added box2d to my project and now I have errors that say:
"Invalid conversion from 'int' to 'BalloonType'
"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!
// .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];
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.
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!
Well, that was a big hammer to use :/
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!
Reference URL's