Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I can't find the tutorials of joints class in the Box2D for iPhone. I am unable to run a Testbed for iPhone Box2D.

(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
       if (_mouseJoint!=NULL)return;
       UITouch *mytouch=[touches anyObject];
       CGPoint location=[mytouch locationInView:[mytouch view]];
       location=[[CCDirector sharedDirector]convertToGL:location];
        b2Vec2 locationWorld=b2Vec2(location.x/PTM_RATIO,location.y/PTM_RATIO);
 //ristrict the player within the ground limit  keep stucking the player with grounditself..... 
if (_playerFixture->TestPoint(locationWorld))
{
    b2MouseJointDef md;
    md.bodyA=groundBody;
    md.bodyB=_playerBody;
    md.target=locationWorld; 
    md.collideConnected=true;
    md.maxForce=100.0f*_playerBody->GetMass();
    _mouseJoint=(b2MouseJoint *)_world->CreateJoint(&md);
    _playerBody->SetAwake(true);
}
}

-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if (_mouseJoint == NULL) return;
UITouch *myTouch = [touches anyObject];
CGPoint location = [myTouch locationInView:[myTouch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
if (location.y<240.00&&location.y>=20.0f)
{
    b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
    _mouseJoint->SetTarget(locationWorld);  
}
}

- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{
if (_mouseJoint) 
{


 _world->DestroyJoint(_mouseJoint);
    _mouseJoint = NULL;


  }  

}
share|improve this question
    
Is iOS Box2D that different than "real" Box2D? –  user744 May 3 '11 at 20:39
    
Freezing Fire, it would help if you'd say what in particular isn't clear about the Box2D manual (which has a huge section on joints), or why Emanuele's tutorials aren't good for you. –  user744 May 5 '11 at 11:00
    
@joe Wreschnig: I Have updated my question ==> here problem is that ==>with use of mouse joint i move the object through the screen and due to the mouse joint object don't getting rigid to the place where my hand is moving and also i am not getting any setter method for ==> b2Vec2 GetReactionForce(float32 inv_dt) const; as i think this is the responsible method for the ball having more elasticity prooperty –  NIKHIL May 5 '11 at 12:52
add comment

2 Answers

up vote 1 down vote accepted
+50

Emanuele Feronato has some great joint tutorials for box2d. The tutorials are in Actionscript 3, but the basic principles are the same.

BTW, the as3 port of box2d sticks pretty closely to the naming convention of the original c++ box2d, so you'll just have to change syntax a bit to use it on the iPhone.

http://www.emanueleferonato.com/category/box2d/

share|improve this answer
    
I've read those, and I think they're far more confusing and shallow than the proper Box2D manual. –  user744 May 4 '11 at 5:51
    
no actually good tutorials and understandable also thank you very much –  NIKHIL May 7 '11 at 5:24
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.