gOzaru

  • 29 mai 2015
  • Inscrit 6 mai 2015
  • Mitch a écrit

    Thanks.

    This is the first time I saw user like u.
    I intended to buy Spine pro after I know how to implement Box2D in cocos2d-x.
    But if I don't know how, or no body guide me; why should I buy this software?

    The example I used I got from the one in internet which had bounding box in it.
    but sadly, this forum is really in desperation. No body help me at all.
    Not even a single guide what to do about the bounding box.

  • Hey guys, could u help me?
    I read the I_Box2D.java

    if (!(slot.getAttachment() instanceof Box2dAttachment)) continue; <
    
    ---
    
     this line
       Box2dAttachment attachment = (Box2dAttachment)slot.getAttachment();
       PolygonShape boxPoly = new PolygonShape();
       boxPoly.setAsBox(attachment.getWidth() / 2 * attachment.getScaleX(),
       attachment.getHeight() / 2 * attachment.getScaleY(), vector.set(attachment.getX(), attachment.getY()),
       attachment.getRotation() * MathUtils.degRad);
    

    I was trying to find Box2DAttachment in spine library in cocos2d-x and didn't find any clue.
    Is there a way where I could get its length and width?

    attachment.getWidth()
    attachment.getHeight()
    attachment.getRotation()
    

    Really? nobody can help me for this?
    Fine.
    This is my limit.
    I'd purchase R.U.B.E.
    This forum sucks.

  • I was having trouble in applying box2d with spine in cocos2d-x-3.4.
    could you guide me out?
    I want to join contest in http://windows.cocos.com
    I have made the arts 30%.
    I need your help if you can help me, I'd give u share if I win the contest.

  • if u add Box2D implementation for cocos2d-x, I'd buy your e-book.
    minimum version 3.5

  • sheado, I tried your code; but when I see the values of shapePoints; everything has the same value
    see my screenshot.
    I used bounding box with 4 vertices.
    still get error.

    if (slotH)
    {
       if (slotH->attachment)
       {
          if (slotH->attachment->type == SP_ATTACHMENT_MESH)
          {
             mesh = (spMeshAttachment*)slotH->attachment;
             spMeshAttachment_computeWorldVertices(mesh, slotH, worldVertices);
             verticesCount = mesh->verticesCount;
             log("Active: SP_ATTACHMENT_MESH, %d", mesh->verticesCount);
          }
          else if (slotH->attachment->type == SP_ATTACHMENT_BOUNDING_BOX)
          {
             boundBox = (spBoundingBoxAttachment*)slotH->attachment;
             spBoundingBoxAttachment_computeWorldVertices(boundBox, slotH->bone, worldVertices);
             verticesCount = boundBox->verticesCount;
             log("Active: SP_ATTACHMENT_BOUNDING_BOX, %d", boundBox->verticesCount);
          }
    
      b2Vec2 gravity;
      gravity.Set(0.0f, -10.0f);
      worldPhysics = new b2World(gravity);
      worldPhysics->SetContinuousPhysics(false);
    
      b2Body *boxBody;
      b2BodyDef boxBodyDef;
      b2FixtureDef boxFixture;
      b2PolygonShape shapeConcave;
    
      boxBodyDef.type = b2BodyType(b2_staticBody);
      boxBodyDef.gravityScale = 0;
      boxBodyDef.bullet = false;
      boxBodyDef.fixedRotation = true;
    
      boxBody = worldPhysics->CreateBody(&boxBodyDef);
    
      b2Vec2 shapePoints[8] = {};
      
      // create the fixture using the world vertices;
      int32 iP = 0;
      for (int32 ii = 0; ii < verticesCount;)
      {
         shapePoints[iP].x = worldVertices[ii] * skelNodeA->getScaleX();
         ++ii;
         shapePoints[iP].y = worldVertices[ii] * skelNodeA->getScaleY();
         ++ii;
         ++iP;      
    
         log("Vertices count: %d, shapePoints: %d", ii, iP);
         if (ii == verticesCount)
         {
            log("After setting all vertices! Try set a polygonShape!");
            shapeConcave.Set(shapePoints, 8);
         }
      }
    
      boxFixture.shape = &shapeConcave;
      boxFixture.density = 10;
      boxFixture.friction = 0.8;
      boxFixture.restitution = 0.6;
    
      boxBody->CreateFixture(&boxFixture);
      boxBody->SetGravityScale(10);
      boxBody->SetAngularDamping(0.1);
      boxBody->SetLinearDamping(0.1);
    
       }
    }
    
    

    It was error when creating the shapeConcave.

    shapeConcave.Set(shapePoints, 8);
    
    

    I just notice that sheado never use these variables:

    float minX = FLT_MAX, minY = FLT_MAX, maxX = -FLT_MAX, maxY = -FLT_MAX;
    

    some users besides sheado use another approach: helg, milos1290.

    1. http://esotericsoftware.com/forum/Cocos2d-x-3-3-How-to-make-bone-to-follow-box2d-body-3952?

    I am really confusing, which one I should trust in this forum.
    and one more thing, the java code of I_Box2D.java seem very different with
    spine library attached in cocos2d-x-3 above.
    Is this forum alive?
    Any admin who can guide cocos2d-x user?
    Really, should we get a dead end like this?
    I intend to buy your Spine Pro, but if the guides is nothing to read.
    Then I'd not buy.
    I'd try Creature.
    hope they would give me free example and its library.