cocos2d x - Trajectory Path Prediction Of a Bouncing Ball Using Box2D in Cocos2dx -
i want predict projectile trajectory of football game in game farm soccer www.crazygames.com/game/farm-soccer. have made projectile trajectory doesn't includes bounces 1 time ball released.
please suggest me something. here image depicting want (please notice projectile path made reddish dots)
here code wrote till : (thanks iforce2d.net)
void drawtrajectory(){ (int = 1; <= 30; i++) { b2vec2 trajectoryposition = gettrajectorypoint(utility::tometers(catapult->getposition()), startvelocity, -i*3); ccsprite* dot = ccsprite::create("dot.png"); dot->setscale(0.3f); addchild(dot, 20,555); dot->setposition(utility::topixels(trajectoryposition)); } } b2vec2 gettrajectorypoint(b2vec2 startingposition,b2vec2 startingvelocity,float n) { float t = 1 / 60.0f; b2vec2 stepvelocity = t * startingvelocity; b2vec2 stepgravity = t * t * world->getgravity(); homecoming startingposition + n * stepvelocity + 0.5f * (n*n+n) * stepgravity; } cocos2d-x box2d prediction projectile
No comments:
Post a Comment