Time for action – using debug draw in your Box2D project
Let's start by creating the project. In my machine, I created a game called MiniPool in my desktop. Here are the steps:
- Open Terminal and enter the following command:
cocos new MiniPool -p com.rengelbert.MiniPool -l cpp -d /Users/rengelbert/Desktop/MiniPool
- Open the new project in Xcode.
- Now navigate to the
Tests
folder inside the Cocos2d-x framework folder. This can be found intests/cpp-tests/Classes
. Then open theBox2DTestBed
folder. - Drag the files
GLES-Render.h
andGLES-Render.cpp
to your project in Xcode. - You can also open the
Box2dTest.cpp
class in the test folderBox2DTest
, as we're going to copy and paste a few of the methods from there. - In the
HelloWorldScene.h
header file, leave the includes in place, but change the class declarations to match these:class HelloWorld : public cocos2d::Layer { public: virtual ~HelloWorld(); HelloWorld(); static cocos2d::Scene* scene(); void initPhysics(...