ios - Movement of Box2d Body in cocos2d-x -
ios - Movement of Box2d Body in cocos2d-x -
i need move box2d body according position received form game center server.
after receiving position update body position using: -
carbody->settransform(b2vec2(serverposition.x,serverposition.y),0);
but moving body inapprotiate manner (for example. body showing somewere lese in screen). @ same time sprite image not moving (attached body).
what did solve positioning problem taken normal sprite image , alter position in update box2d body position.
eg:-
your carbody motion based on server position. move invisibly. b2body without userdata(image)
carmainbody->settransform(b2vec2(serverposition,carmainbody->getposition().y), 0.0f);
here normal sprite image. attch sprite image this
car->setposition(ccp(carmainbody->getposition().x*ptm_ratio,carmainbody->getposition().y*ptm_ratio));
this method worked fine me.
ios cocos2d-x box2d box2d-iphone
Comments
Post a Comment