i am a beginner in cocos2dx and good at libgdx.But libgdx is too detail oreinted and after watching the source code of cocos2dx game its coming naturally to me.
I want to learn the Box2d implementation in cocos2dx using eclipse on windows.Because i found the same thing(box2d) in libgdx very flexible and it gives life to your game.
I have downloaded the cocos2dx 2.0.1 version and want to know how to use box2d in my game.
I have downloaded cygwin.Made my first HelloWorld game and i am already in love with cocos.
Hope someone will help me in using Box2d with eclipse on windows for my cocos game.
May i know why i need to install Ubuntu if i already have Cocos2dx setuped on my windows machine(using eclipse) running successfully HelloWorld Project ?
To use box2d, you need to create the “virtual” box2d world that represents a scaled down version of your real world. You could use a scale of 1:1 too if you like.
The box2d world consists of polygons, circles, rectangles, etc. These are then used to test intersection and perform physics solutions.
If C++ and Windows is the way you are familiar with coding, then you are good to go. You should be able to build the Windows8 project on your box, if it is Windows 8 of course.
If you were a .NET developer then you could also use the cocos2d-xna variant of the library which also has a direct port of box2d in it.
Hi Ram, I am not familiar with the hello world project. Chances are you need to use a physics sprite that knows how to interpret itself in the box2d world, so you can transform it according to the box2d solvers.
For instance, you know that you can put a sprite on the screen and make it rotate and translate on the screen. Now you create the box2d world, create a rectangle for your sprite, give it physical properties (the rectangle), and make it do something in box2d by assigning a force to it. Nothing happens. Boo.
So then you setup the box2d query callbacks so you are told when things move. Then you use those callbacks to adjust the properties of your sprite that is assigned to the rectangle (b2Body). The smarter way is to assign the b2Body to your sprite (a physics sprite now), and let the sprite intercept callbacks from box2d so that it manages itself. viola! now your sprite moves with the rectangle in box2d.
Put another sprite in there with an opposite force applied, and watch them collide!
but there(in libgdx) we need to import the Box2d-imports(box2d required files) via ctrl+shift+o in eclipse manages imports for the java project, to make box2d work…
Do we need some thing similar here too(like the imports) ?
Also HelloWorld is the filename(of C++ source and header files)of the files in the project created (using create-android-project.bat file) using cocos2dx in eclipse for windows
So your question is more of “how to include the box2d libraries in Eclipse” which I do not know. We use Visual Studio and Xamarin Studio here. There is probably some library reference node in the project explorer that would allow you to include the box2d libraries. Maybe when you figure this out, you can add a “create-android-box2d-project.bat” file and push that to the github.
Visual Studio Express
Xamarin Studio Community Edition
all free
MonoGame (.NET/XNA)
free
cocos2d-xna (.NET/XNA)
free
The easiest way to make a cocos2d game is to use cocos2d builder, but that’s not free. Someone needs to make some money somewhere to keep the project alive, right?
There are test project distributed with cocos sources, in directory samples/Cpp/TestCpp. Just build&run this app and find Box2D in examples list. Than look how it implemented in sources.
its off-point but why have you suggested to install linux to me ??
Next i am using cocos2dx 2.0.1…
in this we have a folder called ‘test’…inside it there are various topics in which one is ‘Box2dTest’…
when i go into this folder it only includes ‘Box2dTest.cpp’ and ‘Box2dTest.h’ files nothing else
when i see in ‘test’ folder there is test.h and test.cpp but no android.mk or application.mk files present.
Also while searching this forum and on google i found out that this is a big issue from the very beginning and no one has yet solved it (not even developers i think otherwise they would have posted on those various queries about it on this forum)…
Cocos2dx with Box2d using eclipse still a dream incomplete