iphone - collision detection of two objects in different class -


i calling 2 different object 2 different node in rock.h

@interface rock : ccnode {  int screenwidth; int screenheight; float downwardspeed;  }  @property (nonatomic, retain) ccsprite *falling_rock;  -(void) makeenemygolower; -(cgsize)contentsize_ofbugsprite; -(cgrect)boundingbox_forrock; end 

in rock .m

-(cgrect)boundingbox_forrock {   return  falling_rock.boundingbox; }  -(cgsize)contentsize_ofbugsprite  {  return falling_rock.contentsize; }  -(void) runenemyanimationsequence:(cctime) delta {  self.position = ccp(self.position.x, self.position.y - downwardspeed  );  } 

similarly player class also. calling in main game class using ccnode position in nslog not coming correct.so unable check collision.

please help, mistake making?

i'm not sure if syntax correct since use cocos2d-x, believe issue both boundingboxes have in world space. can use converttoworldspace method position local space world space.

should this:

-(cgrect)boundingbox_forrock {     cgpoint worldposition = converttoworldspace(getposition());     return cgrectmake(worldposition.x, worldposition.y, getcontentsize().width, getcontentsize().height); } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -