ios - make physics body jump in cocos2d-Box2d -


i newbie gaming world stuccoed make physics body jump..
here how defined body

cycle = [ccsprite spritewithfile:@"panda.png"];         [self addchild:cycle z:3];      // create world     b2vec2 gravity = b2vec2(0.0f, -8.0f);     world = new b2world(gravity);      // create edges around entire screen     b2bodydef groundbodydef;     groundbodydef.position.set(0,0);      b2body *groundbody = world->createbody(&groundbodydef);     b2edgeshape groundedge;     b2fixturedef boxshapedef;     boxshapedef.shape = &groundedge;      //wall definitions     groundedge.set(b2vec2(0,0), b2vec2(screensize.width/ptm_ratio, 0));     groundbody->createfixture(&boxshapedef);      groundedge.set(b2vec2(0,0), b2vec2(0,screensize.height/ptm_ratio));     groundbody->createfixture(&boxshapedef);      groundedge.set(b2vec2(0, screensize.height/ptm_ratio),                    b2vec2(screensize.width/ptm_ratio, screensize.height/ptm_ratio));     groundbody->createfixture(&boxshapedef);      groundedge.set(b2vec2(screensize.width/ptm_ratio, screensize.height/ptm_ratio),                    b2vec2(screensize.width/ptm_ratio, 0));     groundbody->createfixture(&boxshapedef);      // create ball body , shape     b2bodydef ballbodydef;     ballbodydef.type = b2_dynamicbody;     ballbodydef.position.set(300/ptm_ratio,100/ptm_ratio);     ballbodydef.userdata = cycle;     body = world->createbody(&ballbodydef);       b2polygonshape dynamicbox;     dynamicbox.setasbox(.5f, .5f);//these mid points our 1m box      // define dynamic body fixture.     b2fixturedef fixturedef;     fixturedef.shape = &dynamicbox;     fixturedef.density = 1.0f;     fixturedef.friction = 0.3f;     body->createfixture(&fixturedef); 

and in touches began applying linear impulse as

b2vec2 force = b2vec2(30, 30); body-> applylinearimpulse(body->getposition(),force); 

so can body tell me doing wrong..
in advance..

have read of article iforce2d. should explain quite bit.

iforce2d - box2d tutorials - jumping


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -