b2Vec2 force = b2Vec2(8.f, 10.0);
b2Vec2 point = ballBody->GetPosition(); //b2Vec2(9.1230, 0.9663);
ballBody->ApplyLinearImpulse(force,point);
what ever point i use the ball will go to first left then up. I want to give it impulse straight up from the ball current position what i m doing wrong please let me know, i tried nearly every kind of point for the position like b2Vec2(9.0f, 20.0f) etc etc.
please any sample code if some one knows ..
This is the Ball Creation Code
CCSprite *ball = [CCSprite spriteWithFile:@"Ball.png" rect:CGRectMake(0, 0, 30, 30)];
ball.position = ccp(305.0, 20.0);
ball.tag = 1;
[self addChild:ball];
// Create ball body
b2BodyDef ballBodyDef;
ballBodyDef.type = b2_dynamicBody;
ballBodyDef.position.Set(100/PTM_RATIO, 100/PTM_RATIO);
ballBodyDef.userData = ball;
ballBody = world->CreateBody(&ballBodyDef);
// Create circle shape
b2CircleShape circle;
circle.m_radius = 15.0/PTM_RATIO;
// Create shape definition and add to body
b2FixtureDef ballShapeDef;
ballShapeDef.shape = &circle;
ballShapeDef.density = 1.5f;
ballShapeDef.friction = 0.0f; // We don't want the ball to have friction!
ballShapeDef.restitution = 0.4f;
ballFixture = ballBody->CreateFixture(&ballShapeDef);
//And this is the impulse code
b2Vec2 force = b2Vec2(8.f, 10.0);
b2Vec2 point = ballBody->GetWorldPoint(b2Vec2(0.f,0.f));
ballBody->ApplyLinearImpulse(force,point);
what ever point i use the ball first move to left then up from its current location , I tried many points to including +ve and -ve point but not succeeded yet , what i want to apply impulse on a ball straight up from its current location how can i do this, what i am doing wrong ..
If I'm understanding you problem correctly then you need to look Vectors bit. In the mean time try making the X component of the impulse 0.