xcode - contact listener on a general body -


using box2d , cocos2d, having problem on defining bodies. each sprite have calling function defines body,shape,fixture, , function gets argument of caller sprite.

now in order not write mant code each sprite because going have many sprites.

in contact listener have :

if ((contact.fixturea == _bottomfixture && contact.fixtureb == _ballfixture) || ... 

now,because function defines fixture , body general, dont have fixture name each body, hence, dont know how can give listener specific fixture of body.

the function each sprite calls define fixture , body :

- (void)addboxbodyforsprite:(ccsprite *)sprite {      b2bodydef spritebodydef;     spritebodydef.type = b2_dynamicbody;     spritebodydef.position.set(sprite.position.x/ptm_ratio,sprite.position.y/ptm_ratio);     spritebodydef.userdata = sprite;     spritebody = world->createbody(&spritebodydef);      b2circleshape spriteshape; //b2polygon-for box shape     spriteshape.m_radius = 35.0/ptm_ratio;     //spriteshape.setasbox(sprite.contentsize.width/ptm_ratio/2,sprite.contentsize.height/ptm_ratio/2); //for b2polygon     b2fixturedef spriteshapedef;     spriteshapedef.shape = &spriteshape;     spriteshapedef.density = 10.0;     spriteshapedef.issensor = false;     spritebody->createfixture(&spriteshapedef);  } 

and see gets sprite argument , not every sprite has own fixture name. should ? dont want define fixture each sprite ?

thanks lot .


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -