Hi!
I have initialized the box2d physics and a shape here in init()
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
float PTM_RATIO = 32.0;
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
CCLOG("123123123");
b2Vec2 gravity;
gravity.Set(0.0f, -10.0f);
world = new b2World(gravity);
world->SetAllowSleeping(true);
world->SetContinuousPhysics(true);
this->addChild(B2DebugDrawLayer::create(world, PTM_RATIO), 9999);
b2BodyDef myBodyDef;
myBodyDef.type = b2_staticBody; //this will be a dynamic body
myBodyDef.position.Set(0, 20); //set the starting position
myBodyDef.angle = 0; //set the starting angle
b2Body* dynamicBody = world->CreateBody(&myBodyDef);
b2PolygonShape boxShape;
boxShape.SetAsBox(1, 1);
b2FixtureDef boxFixtureDef;
boxFixtureDef.shape = &boxShape;
boxFixtureDef.density = 1;
dynamicBody->CreateFixture(&boxFixtureDef);
return true;
}
According to the tutorial I am following I should be able to see this:
But my screen is just black. What can I do to get the same result as in the image above?
Thank you!