0

i am using box2d to developed iphone game.But i have not a lot of experience.I move a body to a location using this code

body->SetTransform(b2Vec2(posx2,posy2), 0);

and the body does move.But i need it to move with animation.in objective c i use UIView Animation to do similar type of things. can anyone tell how it possible in cocos2d box2d??

1
  • ok...i figure it out at last....
    – Rony
    Commented Oct 14, 2010 at 13:04

1 Answer 1

0

This the way i did this.....

switch of the default tick method using /.../ and move the body manually...

b->SetTransform(b2Vec2(posx1, posy1), 0);
id action = [CCMoveTo actionWithDuration:0.4 position:CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO)];
[sprite runAction:action];

another way:

don't comment off the tick....and inside tick instead of these:

myActor.position = CGPointMake( b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO);
            myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());

you can reset position with animation as like the above....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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