PhysicsJointDistance simple example

Hi everyone
I create two physics body (Boxes) and I`m try use for them PhysicsJointDistance.
But when I run project I see that my application has crashed

If I remove code with PhysicsJointDistance, my application is good working…

This code I put in init function:

    // physics body 1
    auto sp_1 = Sprite::create("CloseNormal.png");
    sp_1->setPosition(Vec2(visibleSize.width/3, visibleSize.height/2));
    auto body_1 = PhysicsBody::createBox(sp_1->getContentSize(), PhysicsMaterial(0,1,0));
    sp_1->setPhysicsBody(body_1);
    this->addChild(sp_1);


    // physics body 2
    auto sp_2 = Sprite::create("CloseSelected.png");
    sp_2->setPosition(Vec2(visibleSize.width/2, visibleSize.height/2));
    auto body_2 = PhysicsBody::createBox(sp_2->getContentSize(), PhysicsMaterial(0,1,0));
    sp_2->setPhysicsBody(body_2);
    this->addChild(sp_2);

    //	 joints
    auto joint = PhysicsJointDistance::construct(body_1, body_2, Vec2::ZERO, Vec2::ANCHOR_TOP_RIGHT);
    joint->setCollisionEnable(false);
    //joint->setDistance(50);
    sceneWorld->addJoint(joint);

Your code seems to be fine. Do you use Visual Studio? You can track the call stack when it’s crashed.

Ok… Now I run application for win32 (not android) and I have error:

error running code 255

I open project in VC and run app again
Now I have this error:

Unhandled exception at 0x008075B6 in MyCppGame.exe: 0xC0000005: Access violation reading location 0xCDCDCDCD.

This exception generated on

sceneWorld->addJoint(joint);

In debbuger I see that PhysicsJointDistance (joint value) has constructed

joint	0x080f9f48 {_anchr1={x=0.000000000 y=0.000000000 } _anchr2={x=1.00000000 y=1.00000000 } }	cocos2d::PhysicsJointDistance *

Really I dont know, why my app crashed