Box2D 2.3.2 and cocos2d v3

Discuss issues specific to using Box2D on the iPhone
Anderson
Posts: 3
Joined: Sun Jul 20, 2014 8:18 am

Box2D 2.3.2 and cocos2d v3

Postby Anderson » Sun Jul 20, 2014 8:31 am

Hi. I want to create a iOS 2d game. I have experience in app creations but I haven't many knowledge in game programming.
I analyzed main game sdks and engines. I chosen a cocos2d+box2d. But a new version of cocos go only with chipmunk.

I siting 2 days and trying create a simple project with cocos2d v3.1 + box2d v 2.3.2, however i have problem;)
I have problem with building box2d and adding it to cocos game project in Xcode. I tried all Google))

Main question:
May someone give me a step by step instruction from downloading box2d to compiling a simple app for iOS. You will be a top people in world for me)

Thanks very much!

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Box2D 2.3.2 and cocos2d v3

Postby irresistible force » Mon Jul 21, 2014 3:55 am

You can add all the Box2D source code files to your project, is probably as easy as any other way. iirc that's what the old project template did anyway.
This page might help: http://www.iforce2d.net/b2dtut/setup-ios
The first part shows how you can add Box2D files to an Xcode project. The screenshots are from Xcode 3 but the basic procedure should be the same with newer Xcode versions.
If you follow that guide, remember to get the latest download of Box2D, not the one linked to in that page!

Anderson
Posts: 3
Joined: Sun Jul 20, 2014 8:18 am

Re: Box2D 2.3.2 and cocos2d v3

Postby Anderson » Tue Jul 22, 2014 2:42 am

irresistible force wrote:You can add all the Box2D source code files to your project, is probably as easy as any other way. iirc that's what the old project template did anyway.
This page might help: http://www.iforce2d.net/b2dtut/setup-ios
The first part shows how you can add Box2D files to an Xcode project. The screenshots are from Xcode 3 but the basic procedure should be the same with newer Xcode versions.
If you follow that guide, remember to get the latest download of Box2D, not the one linked to in that page!


Thanks, but I tried this manual certain times. It doesn't work for Xcode 5 and new Box2d(v2.3.2) and old too(
Maybe there are more ways/instructions?

Anderson
Posts: 3
Joined: Sun Jul 20, 2014 8:18 am

Re: Box2D 2.3.2 and cocos2d v3

Postby Anderson » Tue Jul 22, 2014 3:29 am

irresistible force wrote:You can add all the Box2D source code files to your project, is probably as easy as any other way. iirc that's what the old project template did anyway.
This page might help: http://www.iforce2d.net/b2dtut/setup-ios
The first part shows how you can add Box2D files to an Xcode project. The screenshots are from Xcode 3 but the basic procedure should be the same with newer Xcode versions.
If you follow that guide, remember to get the latest download of Box2D, not the one linked to in that page!


I compiled it! However, when I try to #import "Box2D.h" compiler show many errors.Without including it compiling good.

Code: Select all

In file included from /Users/Oksana/Documents/iOSProjects/eeee/eeee/Classes/IntroScene.m:11:
In file included from Box2D_v2.3.2/Box2D/Box2D/Box2d.h:34:
Box2D_v2.3.2/Box2D/Box2D/Common/b2Settings.h:149:8: error: must use 'struct' tag to refer to type 'b2Version'
extern b2Version b2_version;
       ^
       struct
In file included from /Users/Oksana/Documents/iOSProjects/eeee/eeee/Classes/IntroScene.m:11:
In file included from Box2D_v2.3.2/Box2D/Box2D/Box2d.h:35:
In file included from Box2D_v2.3.2/Box2D/Box2D/Common/b2Draw.h:22:
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:28:14: error: use of undeclared identifier 'reinterpret_cast'
        int32 ix = *reinterpret_cast<int32*>(&x);
                    ^
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:28:31: error: unexpected type name 'int32': expected expression
        int32 ix = *reinterpret_cast<int32*>(&x);
                                     ^
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:28:37: error: expected expression
        int32 ix = *reinterpret_cast<int32*>(&x);
                                           ^
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:56:2: error: type name requires a specifier or qualifier
        b2Vec2() {}
        ^
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:56:10: error: expected ';' at end of declaration list
        b2Vec2() {}
                ^
                ;
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:147:2: error: type name requires a specifier or qualifier
        b2Vec3() {}
        ^
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:147:10: error: expected ';' at end of declaration list
        b2Vec3() {}
                ^
                ;
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:186:2: error: type name requires a specifier or qualifier
        b2Mat22() {}
        ^
Box2D_v2.3.2/Box2D/Box2D/Common/b2Math.h:186:11: error: expected ';' at end of declaration list
        b2Mat22() {}

irresistible force
Posts: 1991
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Box2D 2.3.2 and cocos2d v3

Postby irresistible force » Tue Jul 22, 2014 6:08 am

Box2D is C++, not ObjectiveC. So you don't #import, you #include.
You also need to change the file extension of any files that include C++ to be .mm, not .m
Search for the text "magically taken care of" in that page, it is mentioned there.

EDIT: Actually, I'm not so sure about my first statement there... import may work fine.


Return to “iPhone”



Who is online

Users browsing this forum: No registered users and 1 guest