Spin a CCSprite(wheel) from a user touch

i need functionality like spinniing wheel (exactly same like this link:- http://www.cocos2d-iphone.org/forums/topic/spinning-a-ccsprite-from-a-user-flick/ ) but the link is in cocos2d. i converted that in to cocos2d-x.
in init:-

    //add wheel
    wheel = CCSprite::create(WHEEL_ROTATEWHEEL_SCREEN);
    wheel->setPosition(CCPoint(visibleSize.width/2 + origin.x, visibleSize.height/2 - 40 ));
    this->addChild(wheel, 0);
    
    // Create paddle body
    b2BodyDef paddleBodyDef;
    paddleBodyDef.type = b2_dynamicBody;
    paddleBodyDef.position.Set(visibleSize.width/2 + origin.x/PTM_RATIO, visibleSize.height/2 - 40/PTM_RATIO );
    paddleBodyDef.userData = wheel;
    spinnerBody = world->CreateBody(&paddleBodyDef);
    
    // Create paddle shape
    b2PolygonShape paddleShape;
    paddleShape.SetAsBox(wheel->getContentSize().width/PTM_RATIO/2,
                         wheel->getContentSize().height/PTM_RATIO/2);
    
    // Create shape definition and add to body
    b2FixtureDef paddleShapeDef;
    paddleShapeDef.shape = &paddleShape;
    paddleShapeDef.density = 10.0f;
    paddleShapeDef.friction = 0.4f;
    paddleShapeDef.restitution = 0.1f;
    spinnerFixture = spinnerBody->CreateFixture(&paddleShapeDef);
    
        
    // in C++ you need to initialize objects to NULL
    _mouseJoint = NULL;

here is my touches code.

void wheel::ccTouchEnded(CCTouch* touch, CCEvent* event)
{
    if (_mouseJoint) {
        world->DestroyJoint(_mouseJoint);
        _mouseJoint = NULL;
    }
}
void wheel::ccTouchMoved(CCTouch* touch, CCEvent* event)
{
    if (_mouseJoint == NULL) return;
    
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);

    
    _mouseJoint->SetTarget(locationWorld);
}
bool wheel::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{

    if (_mouseJoint != NULL) return true;
   
    CCPoint location = pTouch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
    
    
    if (spinnerFixture->TestPoint(locationWorld)) 
    {
        b2BodyDef bodyDef;
        groundBody = world->CreateBody(&bodyDef);
        b2MouseJointDef md ;
        md.bodyA = groundBody;
        md.bodyB = spinnerBody;
        md.target = locationWorld;
        md.collideConnected = true;
        md.maxForce = 1000.0f * spinnerBody->GetMass();
        
        _mouseJoint = (b2MouseJoint*)world->CreateJoint(&md);
        spinnerBody->SetAwake(true);
    }
    return true;
}

i got crashed in this line:- spinnerBody = world->CreateBody(&paddleBodyDef);

@srinivas
Is this issue resolved?
if done, can you please share the solution

This is a very old topic. A lot has changed in 4 years.

You want to spin a circle around?

RotateBy?

@slackmoehrle
Definatelly i will use rotate by but i need to show some collision with needle as i am making wheel of fortune so i will need box2d

Or built in physics wil do the trick. Set bitmasks for contract and collision tests.

@slackmoehrle
Ok Thanks I will try this