Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In <code>android.mk</code> you have to add <code>GLESDebugDraw.cpp</code> and also include <code>GLESDebugDraw.h</code> in your .cpp file where you are using it.</p> <p>If you want to debug draw then you have to write only these line in the your draw method</p> <pre><code>CCLayer::draw(); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); kmGLPushMatrix(); world-&gt;DrawDebugData(); kmGLPopMatrix(); </code></pre> <p>In your init method or constructor</p> <pre><code>debugDraw = new GLESDebugDraw(PTM_RATIO); world-&gt;SetDebugDraw(debugDraw); uint32 flags = 0; flags += b2Draw::e_shapeBit; // flags += b2Draw::e_jointBit; /*flags += b2Draw::e_aabbBit; flags += b2Draw::e_pairBit; flags += b2Draw::e_centerOfMassBit;*/ debugDraw-&gt;SetFlags(flags); </code></pre> <p>Try this, This is my init method............</p> <pre><code> bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !CCLayer::init() ) { return false; } this-&gt;setTouchEnabled(true); CCSize visibleSize = CCDirector::sharedDirector()-&gt;getVisibleSize(); CCPoint origin = CCDirector::sharedDirector()-&gt;getVisibleOrigin(); array2-&gt;createWithCapacity(4); b2Vec2 gravity; gravity.Set(0.0f, -10.0f); _world = new b2World(gravity); _world-&gt;SetContactListener(this); // Do we want to let bodies sleep? _world-&gt;SetAllowSleeping(false); _world-&gt;SetContinuousPhysics(true); _debugDraw = new GLESDebugDraw(PTM_RATIO); _world-&gt;SetDebugDraw(_debugDraw); uint32 flags = 0; flags += b2Draw::e_shapeBit; // flags += b2Draw::e_jointBit; // flags += b2Draw::e_aabbBit; // flags += b2Draw::e_pairBit; // flags += b2Draw::e_centerOfMassBit; _debugDraw-&gt;SetFlags(flags); ///////////////////////////// // 2. add a menu item with "X" image, which is clicked to quit the program // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, menu_selector(HelloWorld::menuCloseCallback)); pCloseItem-&gt;setPosition(ccp(origin.x + visibleSize.width - pCloseItem-&gt;getContentSize().width/2 , origin.y + pCloseItem-&gt;getContentSize().height/2)); // create menu, it's an autorelease object CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); pMenu-&gt;setPosition(CCPointZero); this-&gt;addChild(pMenu, 1); ///////////////////////////// // 3. add your codes below... // add a label shows "Hello World" // create and initialize a label CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24); // position the label on the center of the screen pLabel-&gt;setPosition(ccp(origin.x + visibleSize.width/2, origin.y + visibleSize.height - pLabel-&gt;getContentSize().height)); // add the label as a child to this layer this-&gt;addChild(pLabel, 1); // add "HelloWorld" splash screen" CCSprite* pSprite = CCSprite::create("HelloWorld.png"); // position the sprite on the center of the screen pSprite-&gt;setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); // add the sprite as a child to this layer // this-&gt;addChild(pSprite, 0); plbdy(); schedule(SEL_SCHEDULE(&amp;HelloWorld::update), 0); return true; } </code></pre> <p>This is my <code>plbdy()</code> </p> <pre><code>plbdy() { b2BodyDef bdf ; bdf.type = b2_dynamicBody; b2PolygonShape shape; shape.SetAsBox(1,1); b2FixtureDef fd; fd.shape = &amp;shape; fd.density = 1; b2Body hero = _world-&gt;CreateBody(&amp;bdf2); hero-&gt;CreateFixture(&amp;fd); } </code></pre> <p>And This is my Box2d update method to update world</p> <pre><code>update(float dt) { int velocityIterations = 8; int positionIterations = 1; _world-&gt;Step(dt, velocityIterations, positionIterations); } </code></pre> <p>'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</p> <pre><code>Try these make a simple body nothing more and then check body is created or not </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload