How to apply a force which should not be continuos

Posted by sohan on Stack Overflow See other posts from Stack Overflow or by sohan
Published on 2010-04-15T12:39:11Z Indexed on 2010/04/15 12:43 UTC
Read the original article Hit count: 185

Filed under:

I have a body which I move with the help of a button,here is what Im doing

-(void) step: (ccTime) delta { int steps = 2; CGFloat dt = delta/(CGFloat)steps;

for(int i=0; iactiveShapes, &eachShape, nil); cpSpaceHashEach(space->staticShapes, &eachShape, nil);

if(MoveBody)
{

cpFloat movementPadding = 0.1; cpBodyApplyForce(body, cpvmult(ccp( 10, 0), movementPadding), cpvzero);
} else cpBodyResetForces(body); }

I just want to stop the body moving whenever the condition fails,I am trying to reset all forces to 0 with cpBodyResetForces(body),but this never work,it just keep on moving.

can anyone help me how can I stop the body moving?

© Stack Overflow or respective owner

Related posts about cocos2d-iphone