Hi all. I have some trouble when i call:
Code:
cpBodeApplyImpulse(cpBody *body, cpVect j, cpVect r)
My problem is that a ball is spinning after i call cpBodeApplyImpulse. How can i change it behavior such that the ball wouldn't spin at all?
here is code of creating of the ball:
Code:
ballSprite = [CCSprite spriteWithFile:@"ball.png"];
[_tileMap addChild:ballSprite z:2];
//[self addChild:ballSprite z:3];
ballSprite.position = cpv(x,y);
cpBody *someBody = cpBodyNew(10, 10);
someBody->p = ccp(x, y);
cpSpaceAddBody(space, someBody);
player = cpCircleShapeNew(someBody, 10, cpvzero);
player->e = 0.5f;
player->u = 0.5f;
player->data = ballSprite;
cpSpaceAddShape(space, player);
here is code where i call cpBodeApplyImpulse:
Code:
- (void) ccTouchesBegan: (NSSet *)touches withEvent: (UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint pos = [touch locationInView:nil];
pos = [[CCDirector sharedDirector] convertToGL:pos];
if (pos.y>upRect.origin.y && pos.y<upRect.origin.y + 55) {
CGPoint playerPos = [(CCSprite *)(player->data) position];
playerPos = [[CCDirector sharedDirector] convertToGL:playerPos];
cpBodyApplyImpulse(player->body, CGPointMake(playerPos.x, playerPos.y), CGPointMake(playerPos.x, playerPos.y+1000));
}
}
If need i can attach the rest of my code.